﻿using DX_Recognize.AuxiliaryTool;
using DX_Recognize.Common;
using DX_Recognize.Disposition;
using DX_Recognize.Entitys;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml.Linq;
using ZWCAD;
using ZwSoft.ZwCAD.ApplicationServices;
using ZwSoft.ZwCAD.Colors;
using ZwSoft.ZwCAD.DatabaseServices;
using ZwSoft.ZwCAD.DatabaseServices.Filters;
using ZwSoft.ZwCAD.EditorInput;
using ZwSoft.ZwCAD.Geometry;
using ZwSoft.ZwCAD.PlottingServices;
using ZwSoft.ZwCAD.Publishing;
using static DX_Recognize.Utils.ConvertUtils;
using static System.Net.Mime.MediaTypeNames;
using static System.Windows.Forms.LinkLabel;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;

namespace DX_Recognize.Utils
{
    //运算辅助类
    public class ComputedUtils
    {
        //Distributor Board Line  Isometric matching strategy
        public CandidateMixInfo AssemEstStrategy(Boolean IShapedF, List<FullInfoLine> OriginList, List<double> FTVBoardXList)
        {
            SpcialAssemType assmeType = SpcialAssemType.Normal;
            CandidateMixInfo Info = new CandidateMixInfo();
            List<FullInfoLine> RargetRoundList = new List<FullInfoLine>();
            List<FullInfoLine> OperLineList = (List<FullInfoLine>)ConvertUtils.DeepCopyObject(OriginList);
            //Filter Disturb
            double RefL = RecognizeUtils.WholeTopViewData.MostLLength * 0.3;
            List<double> TVTraitValueList = new List<double>();
            FTVBoardXList = FTVBoardXList.Distinct().ToList();
            if (FTVBoardXList.Count > 1)
            {
                for (int fi = 0; fi < FTVBoardXList.Count - 1; fi++)
                {
                    int gi = fi + 1;
                    double DicL = Math.Round(FTVBoardXList[gi] - FTVBoardXList[fi], 0);
                    if (DicL > 40)
                        TVTraitValueList.Add(DicL);
                }
            }

            int hrLastIndex = AssemblyShareData.ASectionList.FindLastIndex(item => item.BoardCode.Equals("hrBoard"));
            int bpFirstIndex = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("bpBoard"));
            Boolean spcialF = hrLastIndex + 1 == bpFirstIndex;
            if (spcialF)
                assmeType = SpcialAssemType.hrOverbp;

            //Same Same Length Line 
            if (OperLineList.Count > 0)
            {
                List<CandidateBLIAboutInfo> TargetAboutInfoList = new List<CandidateBLIAboutInfo>();
                //I Shape 
                double? IBoardL = null;
                //S Shape 
                double? StandL = null;
                //Origin For Compare
                List<CandidateBLIAboutInfo> OriginCorSegList = new List<CandidateBLIAboutInfo>();
                OperLineList.ForEach(item => item.RealLength = Math.Round(item.RealLength, 0));
                List<double> RLList = OperLineList.GroupBy(item => item.RealLength).Where(x => x.Count() > 1).Select(x => x.Key).ToList();
                RLList = RLList.FindAll(item => item >= RefL);
                //First screening
                for (int i = 0; i < RLList.Count; i++)
                {
                    //Permit Error
                    List<FullInfoLine> TempSubItem = OperLineList.FindAll(item => item.RealLength - 2 <= RLList[i] && RLList[i] <= item.RealLength + 2);
                    int TempFirstIndex = OperLineList.FindIndex(item => item.RealLength - 2 <= RLList[i] && RLList[i] <= item.RealLength + 2);
                    int TempLastIndex = OperLineList.FindLastIndex(item => item.RealLength - 2 <= RLList[i] && RLList[i] <= item.RealLength + 2);
                    CandidateBLIAboutInfo CInfo = new CandidateBLIAboutInfo();
                    CInfo.Length = RLList[i];
                    CInfo.AboutLList = TempSubItem;
                    CInfo.LNum = CInfo.AboutLList.Count();
                    CInfo.FirstIndex = TempFirstIndex;
                    CInfo.LastIndex = TempLastIndex;
                    //Set the associated line segment
                    if (TVTraitValueList.Count > 0)
                    {
                        int TVIndex = TVTraitValueList.FindIndex(item => item == CInfo.Length);
                        if (TVIndex != -1)
                            CInfo.TVRelL = TVTraitValueList[TVIndex];
                        else
                        {
                            double MinDif = Math.Abs(TVTraitValueList[0] - RLList[i]);
                            int aboutLIndex = 0;
                            if (TVTraitValueList.Count > 1)
                            {
                                //Find Min Diff  
                                for (int j = 1; j < TVTraitValueList.Count; j++)
                                {
                                    double Dif = Math.Abs(TVTraitValueList[j] - RLList[i]);
                                    if (Dif < MinDif)
                                    {
                                        MinDif = Dif;
                                        aboutLIndex = j;
                                    }
                                }
                            }
                            CInfo.TVRelL = TVTraitValueList[aboutLIndex];
                        }
                    }
                    OriginCorSegList.Add(CInfo);
                }

                if (OriginCorSegList.Count > 0)
                {
                    //Need Be Oper
                    List<CandidateBLIAboutInfo> OperCorSegList = new List<CandidateBLIAboutInfo>(OriginCorSegList);
                    OperCorSegList = OperCorSegList.OrderBy(item => item.LastIndex).ToList();
                    int fpBoardExit = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("fpBoard"));
                    Boolean epBoardExit = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("epBoard")) != -1;
                    int fangtieIndex = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("fangtie"));
                    Boolean epfpF = epBoardExit && (fangtieIndex != -1 && fpBoardExit != -1 && fangtieIndex < fpBoardExit);
                    //I Shape
                    if (IShapedF)
                    {
                        int? IFirstIndex = OriginCorSegList.Min(item => item.FirstIndex);
                        if (IFirstIndex != null)
                        {
                            int IIndex = OriginCorSegList.FindIndex(item => item.FirstIndex == IFirstIndex);
                            //I Shape Board
                            IBoardL = OriginCorSegList[IIndex].Length;
                            OriginCorSegList[IIndex].SType = BoardShapeType.I;
                            CandidateBLIAboutInfo AboutIItem = (CandidateBLIAboutInfo)ConvertUtils.DeepCopyObject(OriginCorSegList[IIndex]);
                            TargetAboutInfoList.Add(AboutIItem);
                            OperCorSegList.RemoveAll(item => item.Length == IBoardL);
                            //Convex Shape Board
                            if (OperCorSegList.Count > 0)
                                for (int i = 0; i < OperCorSegList.Count; i++)
                                    if (OperCorSegList[i].Length > IBoardL)
                                        OperCorSegList[i].SType = BoardShapeType.IPRO;
                            //Normal this Sence Belong to non-standard convex plate
                            List<CandidateBLIAboutInfo> BigIList = OperCorSegList.FindAll(item => item.Length > IBoardL);
                            OperCorSegList.RemoveAll(item => item.Length > IBoardL);
                            if (BigIList.Count > 0)
                            {
                                for (int i = 0; i < BigIList.Count; i++)
                                {
                                    CandidateBLIAboutInfo ProInfo = BigIList[i];
                                    ProInfo.SType = BoardShapeType.IPRO;
                                    CandidateBLIAboutInfo AboutProItem = (CandidateBLIAboutInfo)ConvertUtils.DeepCopyObject(ProInfo);
                                    TargetAboutInfoList.Add(AboutProItem);
                                }
                            }

                            List<CandidateBLIAboutInfo> SmallIList = OperCorSegList.FindAll(item => item.Length < IBoardL);
                            if (SmallIList.Count > 0)
                            {
                                //The default straight body is smaller than I Shape
                                double MinDifL = (double)SmallIList.Min(item => IBoardL - item.Length);
                                int MayBeSInfoIndex = SmallIList.FindIndex(item => IBoardL - item.Length == MinDifL);
                                if (MayBeSInfoIndex != -1)
                                {
                                    CandidateBLIAboutInfo MayBeSInfo = SmallIList[MayBeSInfoIndex];
                                    MayBeSInfo.SType = BoardShapeType.S;
                                    CandidateBLIAboutInfo AboutSItem = (CandidateBLIAboutInfo)ConvertUtils.DeepCopyObject(MayBeSInfo);
                                    TargetAboutInfoList.Add(AboutSItem);
                                    OperCorSegList.RemoveAll(item => item.Length == MayBeSInfo.Length);
                                }
                            }

                            //For epfpBoard
                            int? ILastIndex = TargetAboutInfoList.Find(item => item.SType == BoardShapeType.I)?.LastIndex;
                            int? SLastIndex = TargetAboutInfoList.Find(item => item.SType == BoardShapeType.S)?.LastIndex;
                            if (ILastIndex != null && SLastIndex != null && epfpF)
                            {
                                if (assmeType == SpcialAssemType.hrOverbp)
                                {
                                    int SBoardIndex = OriginCorSegList.FindIndex(item => item.SType == BoardShapeType.S);
                                    if(SBoardIndex != -1)
                                    {
                                        int sLastIndex = (int)OriginCorSegList[SBoardIndex].LastIndex;
                                        double sbL = (double)OriginCorSegList[SBoardIndex].Length;
                                        List<CandidateBLIAboutInfo> scopeEpfpList =  OriginCorSegList.FindAll(item => item.LastIndex < sLastIndex && item.Length < sbL);
                                        if(scopeEpfpList.Count > 0)
                                        {
                                            CandidateBLIAboutInfo electEPFP = scopeEpfpList.Max();
                                            electEPFP.SType = BoardShapeType.EPFP;
                                            CandidateBLIAboutInfo AboutepfpItem = (CandidateBLIAboutInfo)ConvertUtils.DeepCopyObject(electEPFP);
                                            TargetAboutInfoList.Add(AboutepfpItem);
                                        }
                                    }
                                }
                                else
                                {
                                    //Normal Tactics
                                    int IBoardIndex = OriginCorSegList.FindIndex(item => item.Length == IBoardL);
                                    if (IBoardIndex != -1)
                                    {
                                        //I Board Last Index
                                        int? IBLastIndex = OriginCorSegList[IBoardIndex].LastIndex;
                                        if (IBLastIndex != null)
                                        {
                                            //Fit H ShapeLine and smaller than H ShapeLine I ShapeLine
                                            List<CandidateBLIAboutInfo> PPList = OperCorSegList.FindAll(item => item.Length < IBoardL);
                                            if (PPList.Count > 0)
                                            {
                                                //epfpBoard Line Under Frame Board Line 
                                                PPList = PPList.OrderBy(item => item.LastIndex).ToList();
                                                CandidateBLIAboutInfo epfpInfo = PPList[PPList.Count - 1];
                                                epfpInfo.SType = BoardShapeType.EPFP;
                                                CandidateBLIAboutInfo AboutepfpItem = (CandidateBLIAboutInfo)ConvertUtils.DeepCopyObject(epfpInfo);
                                                TargetAboutInfoList.Add(AboutepfpItem);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                    }

                    //H Shape
                    else
                    {
                        //一般底板默认是H的(在直身区域) 最后一块
                        int? bpLastIndex = OperCorSegList.Max(item => item.LastIndex);
                        if (bpLastIndex != null)
                        {
                            CandidateBLIAboutInfo bpInfo = OperCorSegList.Find(item => item.LastIndex == bpLastIndex);
                            StandL = bpInfo.Length;
                            OperCorSegList = new List<CandidateBLIAboutInfo>(OriginCorSegList);
                            OperCorSegList = OperCorSegList.OrderByDescending(item => item.LastIndex).ToList();
                            //Fit
                            List<CandidateBLIAboutInfo> bigthanIInfoList = OriginCorSegList.FindAll(item => item.Length >= StandL);
                            List<CandidateBLIAboutInfo> otherInfoList = OriginCorSegList.FindAll(item => item.Length < StandL);
                            //H Shape 在方铁附近有针板的情况下 默认比H型板小的线长只有一种(下部针板线) 且出现在最后边 
                            if (otherInfoList.Count > 1 && epfpF)
                            {
                                int? epfpLastValue = otherInfoList.Max(item => item.LastIndex);
                                if (epfpLastValue != null)
                                {
                                    OriginCorSegList.Clear();
                                    CandidateBLIAboutInfo epfpInfo = otherInfoList.Find(item => item.LastIndex == epfpLastValue);
                                    OriginCorSegList.Add(epfpInfo);
                                    OriginCorSegList.AddRange(bigthanIInfoList);
                                }
                            }
                            OperCorSegList = OperCorSegList.OrderByDescending(item => item.LastIndex).ToList();
                            List<CandidateBLIAboutInfo> SList = OriginCorSegList.FindAll(item => item.Length == StandL);
                            //一般这个属于非标凸板
                            List<CandidateBLIAboutInfo> BigIList = OriginCorSegList.FindAll(item => item.Length > StandL);
                            if (BigIList.Count > 0)
                            {
                                for (int i = 0; i < BigIList.Count; i++)
                                {
                                    CandidateBLIAboutInfo ProInfo = BigIList[i];
                                    ProInfo.SType = BoardShapeType.IPRO;
                                    CandidateBLIAboutInfo AboutProItem = (CandidateBLIAboutInfo)ConvertUtils.DeepCopyObject(ProInfo);
                                    OperCorSegList.RemoveAll(item => item.Length == BigIList[i].Length);
                                    TargetAboutInfoList.Add(AboutProItem);
                                }
                            }

                            //H Shape
                            if (SList.Count > 0)
                            {
                                for (int i = 0; i < SList.Count; i++)
                                {
                                    SList[i].SType = BoardShapeType.S;
                                    CandidateBLIAboutInfo AboutSItem = (CandidateBLIAboutInfo)ConvertUtils.DeepCopyObject(SList[i]);
                                    TargetAboutInfoList.Add(AboutSItem);
                                }
                                OperCorSegList.RemoveAll(item => item.Length == StandL);
                            }

                            //针对针板
                            int? SLastIndex = TargetAboutInfoList.Find(item => item.SType == BoardShapeType.S)?.LastIndex;
                            if (SLastIndex != null && epfpF)
                            {
                                //排除掉直身 比I板短(针板线和框板线)
                                List<CandidateBLIAboutInfo> PPList = OperCorSegList.FindAll(item => item.Length < StandL);
                                PPList = PPList.OrderBy(item => item.LastIndex).ToList();
                                if (PPList.Count > 0)
                                {
                                    PPList = PPList.OrderBy(item => item.LastIndex).ToList();
                                    CandidateBLIAboutInfo epfpInfo = PPList[PPList.Count - 1];
                                    epfpInfo.SType = BoardShapeType.EPFP;
                                    CandidateBLIAboutInfo AboutepfpItem = (CandidateBLIAboutInfo)ConvertUtils.DeepCopyObject(epfpInfo);
                                    TargetAboutInfoList.Add(AboutepfpItem);
                                }
                            }
                        }

                    }

                    //Filter Some Frame Line witch Same length with epfpBoard 
                    if (TargetAboutInfoList.Count > 0)
                    {
                        if (epfpF)
                        {
                            if (IShapedF)
                            {
                                if (assmeType == SpcialAssemType.Normal)
                                {
                                    int LastSInfoIndex = TargetAboutInfoList.FindIndex(item => item.SType == BoardShapeType.S);
                                    if (LastSInfoIndex != -1)
                                    {
                                        int? LastSIndex = TargetAboutInfoList[LastSInfoIndex].LastIndex;
                                        if (LastSIndex != null)
                                        {
                                            //最后一条直身板线下方
                                            double LastSBoardY = OriginList[(int)LastSIndex].StartPoint.CustomerPoint.Y;
                                            int? epfpIndex = TargetAboutInfoList.FindIndex(item => item.SType == BoardShapeType.EPFP);
                                            if (epfpIndex != null && epfpIndex != -1)
                                            {
                                                List<FullInfoLine> epfpList = TargetAboutInfoList[(int)epfpIndex].AboutLList;
                                                if (epfpList.Count > 0)
                                                {
                                                    epfpList = epfpList.FindAll(item => item.StartPoint.CustomerPoint.Y < LastSBoardY);
                                                    TargetAboutInfoList[(int)epfpIndex].AboutLList = epfpList;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (assmeType == SpcialAssemType.Normal)
                                {
                                    //默认定义:直身型(H型) 倒数第三条线是方铁上方的线
                                    int LastSInfoIndex = TargetAboutInfoList.FindIndex(item => item.SType == BoardShapeType.S);
                                    if (LastSInfoIndex != -1)
                                    {
                                        List<FullInfoLine> SAboutList = TargetAboutInfoList[LastSInfoIndex].AboutLList;
                                        if (SAboutList.Count >= 3)
                                        {
                                            FullInfoLine FangtieAreaTLine = SAboutList[SAboutList.Count - 3];
                                            double FangtieAreaTY = FangtieAreaTLine.StartPoint.CustomerPoint.Y;
                                            int epfpIndex = TargetAboutInfoList.FindIndex(item => item.SType == BoardShapeType.EPFP);
                                            if (epfpIndex != -1)
                                            {
                                                List<FullInfoLine> epfpList = TargetAboutInfoList[(int)epfpIndex].AboutLList;
                                                if (epfpList.Count > 0)
                                                {
                                                    epfpList = epfpList.FindAll(item => item.StartPoint.CustomerPoint.Y < FangtieAreaTY);
                                                    TargetAboutInfoList[(int)epfpIndex].AboutLList = epfpList;
                                                }
                                            }
                                        }
                                    }
                                }
                                
                            }
                        }

                        //扁平化收集信息
                        TargetAboutInfoList.ForEach(item => RargetRoundList.AddRange(item.AboutLList));
                        if (RargetRoundList.Count > 0)
                            RargetRoundList = RargetRoundList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y).ToList();

                    }

                }
                Info.eachBoardInfo = TargetAboutInfoList;
            }
            return Info;
        }

        //处理螺丝加工数据前置(螺丝采用标准 if客户不是通牙 按标准深度会做穿 才按客户图纸)
        public static void PreProcessScrewData(SingleItem SItem)
        {
            SItem.ProcessScrewH = SItem.TheoryScrewH;
            SItem.ToochInfo.ProcessBlindToochH = SItem.ToochInfo.BlindToochH;
            List <StandardScrew> standardScrewList = ParamsConfigData.StandardScrewList;
            int Index = standardScrewList.FindIndex(item => item.Dimension == SItem.Dim);
            if(Index != -1)
            {
                StandardScrew targetScrew = standardScrewList[Index];
                double standardBlindToochDepth = (double)targetScrew.BlindDepth;
                SItem.ToochInfo.ProcessBlindToochH = standardBlindToochDepth;
                //if(SItem.ScrewDimThroughHBList.Count > 0)
                //{
                //    BoardSectionItem lastB = SItem.ScrewDimThroughHBList.Last();
                //    double lastBThick = lastB.PlateThick;
                //    Boolean F = standardToochDepth < lastBThick;
                //    if(F)
                //        SItem.ToochInfo.ProcessBlindToochH = standardToochDepth;
                //    else
                //        SItem.ProcessScrewH = SItem.RealScrewH;
                //}
            }
        }

        //推算组装图中心点坐标 (用于推算分中坐标)
        public static void CalAssemblyRefCenterPoint(List<BoardSectionItem> operList)
        {
            double? resAvgx = null;
            double? resAvgY = null;
            List<double> avgxList = new List<double>();
            if(operList.Count > 0)
            {
                resAvgY = operList.First().OverheadLine.StartPoint.CustomerPoint.Y;
                for (int i = 0; i< operList.Count; i++)
                {
                    double avgX = (operList[i].OverheadLine.StartPoint.CustomerPoint.X + operList[i].OverheadLine.EndPoint.CustomerPoint.X) / 2;
                    avgxList.Add(avgX);
                }
            }
            if(avgxList.Count > 0)
                resAvgx = avgxList.GroupBy(n => n).OrderByDescending(g => g.Count()).First().First();
            if (resAvgx != null)
            {
                AssemblyShareData.AVCCenterInfo.TransF = true;
                AssemblyShareData.AVCCenterInfo.CustomerPoint.X = (double)resAvgx;
            }
            if (resAvgY != null)
                AssemblyShareData.AVCCenterInfo.CustomerPoint.Y = (double)resAvgY;
        }

        //比较 平面图 组装图 客图的绝对坐标是否在可接受偏差范围内
        public static void CompareCustomerDWGABSCoor()
        {
            Boolean Res = false;
            MixedCAD_Point tvCenterInfo = RecognizeUtils.WholeTopViewData.ModlCenterInfo;
            MixedCAD_Point avCenterInfo = AssemblyShareData.AVCCenterInfo;
            CAD_Point TVCPoint = tvCenterInfo.CustomerPoint;
            CAD_Point AVCPoint = avCenterInfo.CustomerPoint;
            Boolean F = TVCPoint.X - 2 <= AVCPoint.X && AVCPoint.X <= TVCPoint.X + 2;
            if (F)
                Res = true;
            AssemblyShareData.avtvAbsCCoorF = Res;
        }

        //转换 组装图(推算出的数据结构) 分中坐标
        public static void TranAssemblyColProInfo(ColProInfo Info)
        {
            CAD_Point CustomRefPoint = AssemblyShareData.AVCCenterInfo.CustomerPoint;
            Dictionary<double, List<MixedCAD_Line>> ItemTSDic = Info.ItemTSLineYDic;
            Dictionary<double, List<MixedCAD_Line>> BLineDic =  Info.BoardTSLineYDic;
            Dictionary<double, List<MixedCAD_Line>> AVDic = Info.AVLineYDic;
            Dictionary<double, List<MixedCAD_Line>> OBDic = Info.OBLineYDic;

            //设置方铁分中
            if(FangtieShareData.FLXInfo.CustomerX != null)
                FangtieShareData.FLXInfo.SplitX = (double)FangtieShareData.FLXInfo.CustomerX - CustomRefPoint.X;
            if (FangtieShareData.FRXInfo.CustomerX != null)
                FangtieShareData.FRXInfo.SplitX = (double)FangtieShareData.FRXInfo.CustomerX - CustomRefPoint.X;
            if(FangtieShareData.NOFLXInfo.F)
                FangtieShareData.NOFLXInfo.SplitX = (double)FangtieShareData.NOFLXInfo.CustomerX - CustomRefPoint.X;
            if (FangtieShareData.NOFRXInfo.F)
                FangtieShareData.NOFRXInfo.SplitX = (double)FangtieShareData.NOFRXInfo.CustomerX - CustomRefPoint.X;

            List<double> ItemTSDicKeys = ItemTSDic.Keys.ToList();
            if(ItemTSDicKeys.Count > 0)
            {
                Dictionary<double, List<MixedCAD_Line>> afterTransDic = new Dictionary<double, List<MixedCAD_Line>>();
                for (int i = 0; i < ItemTSDicKeys.Count; i++)
                {
                    List<MixedCAD_Line> tempItem = ItemTSDic[ItemTSDicKeys[i]];
                    if(tempItem.Count > 0)
                    {
                        for (int j = 0; j < tempItem.Count; j++)
                            CalLineTransToSplit(tempItem[j], CustomRefPoint);
                        double NKey = tempItem.First().StartPoint.TransSplitPoint.Y;
                        afterTransDic.Add(NKey, tempItem);
                    }
                }
                Info.ItemTSLineYDic = afterTransDic;
            }

            List<double> ItemBLDicKeys = BLineDic.Keys.ToList();
            if (ItemBLDicKeys.Count > 0)
            {
                Dictionary<double, List<MixedCAD_Line>> afterTransDic = new Dictionary<double, List<MixedCAD_Line>>();
                for (int i = 0; i < ItemBLDicKeys.Count; i++)
                {
                    List<MixedCAD_Line> tempItem = BLineDic[ItemBLDicKeys[i]];
                    if (tempItem.Count > 0)
                        for (int j = 0; j < tempItem.Count; j++)
                            CalLineTransToSplit(tempItem[j], CustomRefPoint);
                    double NKey = tempItem.First().StartPoint.TransSplitPoint.Y;
                    afterTransDic.Add(NKey, tempItem);
                }
                Info.BoardTSLineYDic = afterTransDic;
            }

            List<double> ItemAVDicKeys = AVDic.Keys.ToList();
            if (ItemAVDicKeys.Count > 0)
            {
                Dictionary<double, List<MixedCAD_Line>> afterTransDic = new Dictionary<double, List<MixedCAD_Line>>();
                for (int i = 0; i < ItemAVDicKeys.Count; i++)
                {
                    List<MixedCAD_Line> tempItem = AVDic[ItemAVDicKeys[i]];
                    if (tempItem.Count > 0)
                        for (int j = 0; j < tempItem.Count; j++)
                            CalLineTransToSplit(tempItem[j], CustomRefPoint);
                    double NKey = tempItem.First().StartPoint.TransSplitPoint.Y;
                    afterTransDic.Add(NKey, tempItem);
                }
                Info.AVLineYDic = afterTransDic;
            }

            List<double> ItemOVDicKeys = OBDic.Keys.ToList();
            if (ItemOVDicKeys.Count > 0)
            {
                Dictionary<double, List<MixedCAD_Line>> afterTransDic = new Dictionary<double, List<MixedCAD_Line>>();
                for (int i = 0; i < ItemOVDicKeys.Count; i++)
                {
                    List<MixedCAD_Line> tempItem = OBDic[ItemOVDicKeys[i]];
                    if (tempItem.Count > 0)
                        for (int j = 0; j < tempItem.Count; j++)
                            CalLineTransToSplit(tempItem[j], CustomRefPoint);
                    double NKey = tempItem.First().StartPoint.TransSplitPoint.Y;
                    afterTransDic.Add(NKey, tempItem);
                }
                Info.OBLineYDic = afterTransDic;
            }

        }

        //根据 平面图&组装图 切换坐标模式 线 (返回合适的坐标类型)
        public static List<CAD_Line> SwitchLineCoorType(List<MixedCAD_Line> argList)
        {
            List<CAD_Line> ResList = new List<CAD_Line>();
            Boolean NOF = !AssemblyShareData.avtvAbsCCoorF;
            if(argList.Count > 0)
            {
                //if (NOF)
                //{
                //    for(int i = 0; i < argList.Count; i++)
                //    {
                //        CAD_Line TempItem = new CAD_Line();
                //        CAD_Point startPoint = argList[i].StartPoint.TransSplitPoint;
                //        CAD_Point endPoint = argList[i].EndPoint.TransSplitPoint;
                //        TempItem.StartPoint = startPoint;
                //        TempItem.EndPoint = endPoint;
                //        ResList.Add(TempItem);
                //    }
                //}
                //else
                //{
                //    for (int i = 0; i < argList.Count; i++)
                //    {
                //        CAD_Line TempItem = new CAD_Line();
                //        CAD_Point startPoint = argList[i].StartPoint.CustomerPoint;
                //        CAD_Point endPoint = argList[i].EndPoint.CustomerPoint;
                //        TempItem.StartPoint = startPoint;
                //        TempItem.EndPoint = endPoint;
                //        ResList.Add(TempItem);
                //    }
                //}
                for (int i = 0; i < argList.Count; i++)
                {
                    CAD_Line TempItem = new CAD_Line();
                    CAD_Point startPoint = argList[i].StartPoint.TransSplitPoint;
                    CAD_Point endPoint = argList[i].EndPoint.TransSplitPoint;
                    TempItem.StartPoint = startPoint;
                    TempItem.EndPoint = endPoint;
                    ResList.Add(TempItem);
                }
            }
            return ResList;
        }

        //平面图 客图孔坐标 -> 相对分中坐标
        public static void CalTViewHoleSplitCoorLogic(List<ScrewHole> argList,CAD_Point RefPoint)
        {
            if(argList.Count > 0)
            {
                for(int i = 0; i < argList.Count; i++)
                {
                    argList[i].CenterPoint.TransSplitPoint.X = argList[i].CenterPoint.CustomerPoint.X - RefPoint.X;
                    argList[i].CenterPoint.TransSplitPoint.Y = argList[i].CenterPoint.CustomerPoint.Y - RefPoint.Y;
                }
            }
        }

        //根据 平面图&组装图 切换坐标模式 孔 (返回合适的坐标类型)
        public static void SwitchTVHoleCoorType(List<ScrewHole> argList)
        {
            for (int i = 0; i < argList.Count; i++)
            {
                argList[i].UseCenterPoint.X = argList[i].CenterPoint.TransSplitPoint.X;
                argList[i].UseCenterPoint.Y = argList[i].CenterPoint.TransSplitPoint.Y;
            }
            //Boolean NOF = !AssemblyShareData.avtvAbsCCoorF;
            //if (NOF)
            //{
            //    for (int i = 0; i < argList.Count; i++)
            //    {
            //        argList[i].UseCenterPoint.X = argList[i].CenterPoint.TransSplitPoint.X;
            //        argList[i].UseCenterPoint.Y = argList[i].CenterPoint.TransSplitPoint.Y;
            //    }
            //}
            //else
            //{
            //    for (int i = 0; i < argList.Count; i++)
            //    {
            //        argList[i].UseCenterPoint.X = argList[i].CenterPoint.CustomerPoint.X;
            //        argList[i].UseCenterPoint.Y = argList[i].CenterPoint.CustomerPoint.Y;
            //    }
            //}
        }

        

        //组装图板 信息 转换 分中
        public static void CalAssemblyBoardRefCoorInfo()
        {
            List<BoardSectionItem> BoardList = AssemblyShareData.ASectionList;
            if (BoardList.Count > 0)
            {
                for (int i = 0; i < BoardList.Count; i++)
                {
                    CalUseBoardTLineCoorLogic(BoardList[i].OverheadLine);
                    CalUseBoardTLineCoorLogic(BoardList[i].BottomLine);
                }
            }
        }

        //设置 板线 实际推算过程中使用的坐标
        public static void CalUseBoardTLineCoorLogic(FullInfoLine Info)
        {
            CAD_Point CustomRefPoint = AssemblyShareData.AVCCenterInfo.CustomerPoint;
            Info.StartPoint.TransSplitPoint.X = Info.StartPoint.CustomerPoint.X - CustomRefPoint.X;
            Info.StartPoint.TransSplitPoint.Y = Info.StartPoint.CustomerPoint.Y - CustomRefPoint.Y;
            Info.EndPoint.TransSplitPoint.X = Info.EndPoint.CustomerPoint.X - CustomRefPoint.X;
            Info.EndPoint.TransSplitPoint.Y = Info.EndPoint.CustomerPoint.Y - CustomRefPoint.Y;

            Info.UseStartPoint.X = Info.StartPoint.TransSplitPoint.X;
            Info.UseStartPoint.Y = Info.StartPoint.TransSplitPoint.Y;
            Info.UseEndPoint.X = Info.EndPoint.TransSplitPoint.X;
            Info.UseEndPoint.Y = Info.EndPoint.TransSplitPoint.Y;

            //Boolean NOF = !AssemblyShareData.avtvAbsCCoorF;
            //if (NOF)
            //{
            //    Info.UseStartPoint.X = Info.StartPoint.TransSplitPoint.X;
            //    Info.UseStartPoint.Y = Info.StartPoint.TransSplitPoint.Y;
            //    Info.UseEndPoint.X = Info.EndPoint.TransSplitPoint.X;
            //    Info.UseEndPoint.Y = Info.EndPoint.TransSplitPoint.Y;
            //}
            //else
            //{
            //    Info.UseStartPoint.X = Info.StartPoint.CustomerPoint.X;
            //    Info.UseStartPoint.Y = Info.StartPoint.CustomerPoint.Y;
            //    Info.UseEndPoint.X = Info.EndPoint.CustomerPoint.X;
            //    Info.UseEndPoint.Y = Info.EndPoint.CustomerPoint.Y;
            //}
        }

        //推算组装图全量分中坐标 To Complete
        public static void CalAllAssemblySplitCoor(AssemViewCADInfo AVInfo)
        {
            CAD_Point CustomRefPoint = AssemblyShareData.AVCCenterInfo.CustomerPoint;
            List<MixedCAD_Line> avList = AVInfo.AVLList;
            List<MixedCAD_Line> acList = AVInfo.ACLList;
            List<MixedCAD_Arc> arcList = AVInfo.AArcList;
            List<MixedCAD_Circle> cirList = AVInfo.ACirList;

            if (avList.Count > 0)
                for (int i = 0; i < avList.Count; i++)
                    CalLineTransToSplit(avList[i], CustomRefPoint);
            if (acList.Count > 0)
                for (int i = 0; i < acList.Count; i++)
                    CalLineTransToSplit(acList[i], CustomRefPoint);
            if (arcList.Count > 0)
                for (int i = 0; i < arcList.Count; i++)
                    CalArcTransToSplit(arcList[i], CustomRefPoint);
            if (cirList.Count > 0)
                for (int i = 0; i < cirList.Count; i++)
                    CalCirTransToSplit(cirList[i], CustomRefPoint);
        }
        
        //Irregularity Draw Rep
        public void RepIrrDrawLineStrategy(AssAddAuxInfo assistInfo, List<FullInfoLine> candidateTLList, List<MixedCAD_Line> OriginList)
        {
            List<MixedCAD_Line> repResList = new List<MixedCAD_Line>();
            CandidateMixInfo judgeInfo = new CandidateMixInfo();
            judgeInfo = AssemEstStrategy(assistInfo.IShapedF, candidateTLList, assistInfo.FTVBoardXList);
            List<BoardLineShapeAndNumType>  shareNumCaseList = CheckCandidateLineNum(assistInfo.IShapedF, judgeInfo);
            Boolean case2F = JudgeCheckNumCase(shareNumCaseList);
            if (!case2F)
            {
                if(shareNumCaseList.Count > 0)
                {
                    List<double> targetLList = new List<double>();
                    List<MixedCAD_Line> OperLineList = (List<MixedCAD_Line>)ConvertUtils.DeepCopyObject(OriginList);
                    for (int i = 0; i < shareNumCaseList.Count; i++)
                    {
                        BoardLineShapeAndNumType temp = shareNumCaseList[i];
                        Boolean lessF = temp.lineNumType == CandidateLineNumType.LESS;
                        if (lessF)
                        {
                            List<double> tempLengthList = temp.lineLengthList;
                            if(tempLengthList.Count > 0)
                                targetLList.AddRange(tempLengthList);
                        }
                    }
                    if(targetLList.Count > 0)
                    {
                        targetLList = targetLList.Distinct().ToList();
                        targetLList.ForEach(item => OperLineList.FindAll(o => o.Length != item));
                        if(OperLineList.Count > 0)
                        {
                            for(int i = 0; i < targetLList.Count; i++)
                            {
                                double diffV = 30;
                                double minV = targetLList[i] - diffV;
                                double maxV = targetLList[i] + diffV;
                                List<MixedCAD_Line> toAddList  = OperLineList.FindAll(item => minV <= item.Length && item.Length <= maxV).ToList();
                                if (toAddList.Count > 0)
                                    repResList.AddRange(toAddList);
                            }
                        }
                    }
                }
            }
            //if (case2F)
            //{
            //    resInfo.CandidateTLineList = judgeInfo.GetAllBoardLineList();
            //    resInfo.ItemTSLineYDic = ItemDic;
            //    return resInfo;
            //}

        }

        //检测候选线(板线)和板的数量对应关系
        public List<BoardLineShapeAndNumType> CheckCandidateLineNum(Boolean IShapedF, CandidateMixInfo Info)
        {
            List<BoardLineShapeAndNumType> resF = new List<BoardLineShapeAndNumType>();
            BoardLineShapeAndNumType epfpInfo = new BoardLineShapeAndNumType();
            epfpInfo.shapeType = MoldLineShareType.EPFP;
            BoardLineShapeAndNumType IInfo = new BoardLineShapeAndNumType();
            IInfo.shapeType = MoldLineShareType.I;
            BoardLineShapeAndNumType SInfo = new BoardLineShapeAndNumType();
            SInfo.shapeType = MoldLineShareType.S;
            List<CandidateBLIAboutInfo> ABList = Info.eachBoardInfo;
            List<BoardSectionItem> BList = AssemblyShareData.ASectionList;
            List<FullInfoLine> allList = Info.GetAllBoardLineList();
            List<BoardSectionItem> epfpBList = AssemblyShareData.ASectionList.FindAll(item => item.BoardCode.Equals("epBoard")
            || item.BoardCode.Equals("fpBoard"));
            BoardSectionItem fangtie = AssemblyShareData.ASectionList.Find(item => item.BoardCode.Equals("fangtie"));
            if (epfpBList.Count > 0 && fangtie != null)
                epfpBList = epfpBList.FindAll(item => item.plateLineNo > fangtie.plateLineNo);
            //Check Board and Line
            if (epfpBList.Count > 0)
            {
                int abepfpIndex = ABList.FindIndex(item => item.SType == BoardShapeType.EPFP);
                if (abepfpIndex != -1)
                {
                    CandidateBLIAboutInfo aboutepfpitem = ABList[abepfpIndex];
                    epfpInfo.lineLengthList.Add((double)aboutepfpitem.Length);
                    int epfpBNum = epfpBList.Count;
                    int epfpLineNum = aboutepfpitem.AboutLList.Count();
                    Boolean epfpF1 = epfpBNum == epfpLineNum;
                    Boolean epfpF2 = epfpBNum + 1 == epfpLineNum;
                    if (epfpF1 || epfpF2)
                        epfpInfo.lineNumType = CandidateLineNumType.CONFORM;
                    else
                    {
                        if (epfpBNum > epfpLineNum)
                            epfpInfo.lineNumType = CandidateLineNumType.LESS;
                        if (epfpLineNum - 1 > epfpBNum)
                            epfpInfo.lineNumType = CandidateLineNumType.MOME;
                    }
                }
                else
                    epfpInfo.lineNumType = CandidateLineNumType.ZERO;
                resF.Add(epfpInfo);
            }
            //I型
            if (IShapedF)
            {
                //I型板(面板和底板有时候会出现码模坑 这样会少1条线)
                List<BoardSectionItem> IBList = new List<BoardSectionItem>();
                //第一件板有凸的外形
                Boolean IExtraSLineF = false;
                //检查I型板 不严谨 Board and Line
                //int tpIndex = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("tpBoard"));
                IBList.Add(AssemblyShareData.ASectionList[0]);
                int bpIndex = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("bpBoard"));
                if (bpIndex != -1)
                    IBList.Add(AssemblyShareData.ASectionList[bpIndex]);
                if (IBList.Count > 0)
                {
                    int abiIndex = ABList.FindIndex(item => item.SType == BoardShapeType.I);
                    if (abiIndex != -1)
                    {
                        CandidateBLIAboutInfo aboutiitem = ABList[abiIndex];
                        IInfo.lineLengthList.Add((double)aboutiitem.Length);
                        int iBNum = IBList.Count;
                        IInfo.lineNum = aboutiitem.AboutLList.Count();
                        Boolean IFNum1 = IInfo.lineNum == iBNum * 2;
                        //少一条的场景(大概率出现热流道板)
                        Boolean IFNum2 = IInfo.lineNum == iBNum * 2 - 1;
                        if (IFNum1 || IFNum2)
                        {
                            IInfo.lineNumType = CandidateLineNumType.CONFORM;
                            if (IFNum2)
                                IExtraSLineF = true;
                        }
                        else
                        {
                            if (IInfo.lineNum < iBNum * 2)
                                IInfo.lineNumType = CandidateLineNumType.LESS;
                            if (IInfo.lineNum > iBNum * 2)
                                IInfo.lineNumType = CandidateLineNumType.MOME;
                        }
                        resF.Add(IInfo);
                    }
                }

                //除针板 I型板 外 其它所有配板
                //不严谨 筛选过滤出 除针板 I型板 外 其它所有配板(目前不考虑热流道板 等)
                List<BoardSectionItem> midBList = AssemblyShareData.ASectionList.FindAll(item => !item.BoardCode.Equals("fangtie"));
                if (midBList.Count > 0 && epfpBList.Count > 0)
                    midBList = midBList.FindAll(item => !(item.BoardCode.Equals("epBoard") || item.BoardCode.Equals("fpBoard")));
                if (midBList.Count > 0 && IBList.Count > 0)
                {
                    List<String> iboardCodeList = IBList.Select(item => item.BoardUID).ToList();
                    midBList = midBList.FindAll(item => !iboardCodeList.Contains(item.BoardUID));
                }
                if (midBList.Count > 0)
                {
                    Boolean noExitFF = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("fangtie")) == -1;
                    //板数量
                    int midBNum = midBList.Count;
                    //匹配计数器
                    int sLineNum = 0;
                    int absIndex = ABList.FindIndex(item => item.SType == BoardShapeType.S);
                    if (absIndex != -1)
                    {
                        List<FullInfoLine> aboutsLList = (List<FullInfoLine>)ConvertUtils.DeepCopyObject(ABList[absIndex].AboutLList);
                        int iproIndex = ABList.FindIndex(item => item.SType == BoardShapeType.IPRO);
                        if (iproIndex != -1)
                        {
                            List<FullInfoLine> aboutiproList = ABList[iproIndex].AboutLList;
                            if (aboutiproList.Count > 0)
                                aboutsLList.AddRange(aboutiproList);
                        }
                        if (aboutsLList.Count > 1)
                        {
                            Dictionary<string, List<FullInfoLine>> colorIndexLDic = new Dictionary<string, List<FullInfoLine>>();
                            aboutsLList = aboutsLList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y).ToList();
                            SInfo.lineLengthList.AddRange(aboutsLList.Select(item => item.RealLength)?.Distinct().ToList());
                            sLineNum = aboutsLList.Count();
                            //按颜色分成N组
                            List<String> colorIndexList = aboutsLList.Select(item => item.MainColorInfo.ColorIndex).Distinct().ToList();
                            Boolean cF1 = colorIndexList.Count > 1;
                            Boolean cF2 = sLineNum > midBNum + 1;
                            if (cF1 && cF2)
                                SInfo.lineNumType = CandidateLineNumType.MOME;
                            else
                            {
                                for (int i = 0; i < aboutsLList.Count - 1; i++)
                                {
                                    int j = i + 1;
                                    double DiffY = aboutsLList[i].StartPoint.CustomerPoint.Y - aboutsLList[j].StartPoint.CustomerPoint.Y;
                                    if (DiffY <= 15)
                                        sLineNum -= 1;
                                }
                            }
                        }
                        else
                            sLineNum = aboutsLList.Count;
                        //没有方铁 线段需要+1
                        if (noExitFF)
                            sLineNum += 1;
                        //线段需要-1
                        if (IExtraSLineF)
                            sLineNum -= 1;
                        Boolean SComF = midBNum == sLineNum;
                        if (SComF)
                            SInfo.lineNumType = CandidateLineNumType.CONFORM;
                        else
                            SInfo.lineNumType = midBNum > sLineNum ? CandidateLineNumType.LESS : CandidateLineNumType.MOME;
                    }
                    resF.Add(SInfo);
                }
            }
            //H型
            else
            {
                Boolean noExitFF = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("fangtie")) == -1;
                //除针板外的所有板 
                List<BoardSectionItem> hBList = AssemblyShareData.ASectionList.FindAll(item => !item.BoardCode.Equals("fangtie"));
                if (hBList.Count > 0 && epfpBList.Count > 0)
                    hBList = hBList.FindAll(item => !(item.BoardCode.Equals("epBoard") || item.BoardCode.Equals("fpBoard")));
                int hBNum = hBList.Count;
                int absIndex = ABList.FindIndex(item => item.SType == BoardShapeType.S);
                List<FullInfoLine> abouthLList = new List<FullInfoLine>();
                if (absIndex != -1)
                    abouthLList.AddRange(ABList[absIndex].AboutLList);
                int abiproIndex = ABList.FindIndex(item => item.SType == BoardShapeType.IPRO);
                if (abiproIndex != -1)
                    abouthLList.AddRange(ABList[abiproIndex].AboutLList);
                SInfo.lineLengthList.AddRange(abouthLList.Select(item => item.RealLength)?.Distinct().ToList());
                int hLineNum = abouthLList.Count();
                //按颜色分成N组
                List<String> colorIndexList = abouthLList.Select(item => item.MainColorInfo.ColorIndex).Distinct().ToList();
                Boolean cF1 = colorIndexList.Count > 1;
                Boolean cF2 = hLineNum > hBNum + 3;
                if (cF1 && cF2)
                    SInfo.lineNumType = CandidateLineNumType.MOME;
                else
                {
                    for (int i = 0; i < abouthLList.Count - 1; i++)
                    {
                        int j = i + 1;
                        double DiffY = abouthLList[i].StartPoint.CustomerPoint.Y - abouthLList[j].StartPoint.CustomerPoint.Y;
                        if (DiffY <= 15)
                            hLineNum -= 1;
                    }
                }
                //没有方铁 线段需要+1
                if (noExitFF)
                    hLineNum += 1;
                if (hLineNum == hBNum + 2)
                    SInfo.lineNumType = CandidateLineNumType.CONFORM;
                else
                    SInfo.lineNumType = hLineNum > hBNum + 2 ? CandidateLineNumType.MOME : CandidateLineNumType.LESS;
                //这里的S 包括了面板和底板
                resF.Add(SInfo);
            }
            return resF;
        }

        //整合判断是否能通过检查
        public Boolean JudgeCheckNumCase(List<BoardLineShapeAndNumType> infoList)
        {
            Boolean res = true;
            for (int i = 0; i < infoList.Count; i++)
            {
                Boolean F1 = infoList[i].lineNumType != CandidateLineNumType.CONFORM;
                if (F1)
                {
                    Boolean F2 = infoList[i].lineNumType != CandidateLineNumType.NONE;
                    if (F2)
                    {
                        res = false;
                        return res;
                    }
                }
            }
            return res;
        }

        //客图坐标 -> 线段 相对分中坐标
        public static void CalLineTransToSplit(MixedCAD_Line targetLine, CAD_Point refPoint)
        {
            targetLine.StartPoint.TransSplitPoint.X = targetLine.StartPoint.CustomerPoint.X - refPoint.X;
            targetLine.StartPoint.TransSplitPoint.Y = targetLine.StartPoint.CustomerPoint.Y - refPoint.Y;
            targetLine.EndPoint.TransSplitPoint.X = targetLine.EndPoint.CustomerPoint.X - refPoint.X;
            targetLine.EndPoint.TransSplitPoint.Y = targetLine.EndPoint.CustomerPoint.Y - refPoint.Y;

            targetLine.StartPoint.UsePoint.X = targetLine.StartPoint.TransSplitPoint.X;
            targetLine.StartPoint.UsePoint.Y = targetLine.StartPoint.TransSplitPoint.Y;

            //Boolean NOF = !AssemblyShareData.avtvAbsCCoorF;
            //if (NOF)
            //{
            //    targetLine.StartPoint.UsePoint.X = targetLine.StartPoint.TransSplitPoint.X;
            //    targetLine.StartPoint.UsePoint.Y = targetLine.StartPoint.TransSplitPoint.Y;
            //}
            //else
            //{
            //    targetLine.StartPoint.UsePoint.X = targetLine.StartPoint.CustomerPoint.X;
            //    targetLine.StartPoint.UsePoint.Y = targetLine.StartPoint.CustomerPoint.Y;
            //}
        }

        //客图坐标 -> 点 相对分中坐标
        public static void CalPointTransToSplit(MixedCAD_Point targetPoint, CAD_Point refPoint)
        {
            targetPoint.TransSplitPoint.X = targetPoint.CustomerPoint.X - refPoint.X;
            targetPoint.TransSplitPoint.Y = targetPoint.CustomerPoint.Y - refPoint.Y;
        }

        //客图坐标 -> 圆弧(起点 中点) 相对分中坐标
        public static void CalArcTransToSplit(MixedCAD_Arc targetArc, CAD_Point refPoint)
        {
            targetArc.StartPoint.TransSplitPoint.X = targetArc.StartPoint.CustomerPoint.X - refPoint.X;
            targetArc.StartPoint.TransSplitPoint.Y = targetArc.StartPoint.CustomerPoint.Y - refPoint.Y;
            targetArc.EndPoint.TransSplitPoint.X = targetArc.EndPoint.CustomerPoint.X - refPoint.X;
            targetArc.EndPoint.TransSplitPoint.Y = targetArc.EndPoint.CustomerPoint.Y - refPoint.Y;
            targetArc.CenterPoint.TransSplitPoint.X = targetArc.CenterPoint.CustomerPoint.X - refPoint.X;
            targetArc.CenterPoint.TransSplitPoint.Y = targetArc.CenterPoint.CustomerPoint.Y - refPoint.Y;
        }

        //客图坐标 -> 圆(圆心) 相对分中坐标
        public static void CalCirTransToSplit(MixedCAD_Circle targetCir, CAD_Point refPoint)
        {
            targetCir.CenterPoint.TransSplitPoint.X = targetCir.CenterPoint.CustomerPoint.X - refPoint.X;
            targetCir.CenterPoint.TransSplitPoint.Y = targetCir.CenterPoint.CustomerPoint.Y - refPoint.Y;
        }

        //客图
        public static void CalCoaTagTransToSplit(HoleGroupTag tag, CAD_Point refPoint)
        {
            //tag
            List<MixedCAD_Point> CollectionHPList = tag.CollectionHPList;
            if(CollectionHPList.Count > 0)
            {
                for(int i = 0; i < CollectionHPList.Count; i++)
                {
                    CollectionHPList[i].TransSplitPoint.X = CollectionHPList[i].CustomerPoint.X - refPoint.X;
                    CollectionHPList[i].TransSplitPoint.Y = CollectionHPList[i].CustomerPoint.Y - refPoint.Y;
                }
            }
        }

        //设置 平面图 客图坐标 -> 相对分中坐标
        public void ImTVPixFullRefCoor(TopViewCADInfo TVInfo)
        {
            List<MixedCAD_Line> TVLList = TVInfo.TVLList;
            List<MixedCAD_Circle> TVCirList = TVInfo.TVCirList;
            List<MixedCAD_Text> TVTextList = TVInfo.TVTextList;
            MixedCAD_Point ModlPInfo = RecognizeUtils.WholeTopViewData.ModlCenterInfo;
            if (ModlPInfo.TransF)
            {
                CAD_Point refPoint = ModlPInfo.CustomerPoint;
                if (TVLList.Count > 0)
                {
                    for (int i = 0; i < TVLList.Count; i++)
                    {
                        MixedCAD_Line Item = (MixedCAD_Line)ConvertUtils.DeepCopyObject(TVLList[i]);
                        if (Item.SPChamferFlag)
                            CalLineTransToSplit(Item.SCLine, refPoint);
                        if (Item.EPChamferFlag)
                            CalLineTransToSplit(Item.ECLine, refPoint);
                        CalPointTransToSplit(Item.StartPoint, refPoint);
                        CalPointTransToSplit(Item.EndPoint, refPoint);
                    }
                }
                for (int i = 0; i < TVCirList.Count; i++)
                {
                    MixedCAD_Circle Item = (MixedCAD_Circle)ConvertUtils.DeepCopyObject(TVCirList[i]);
                    CalPointTransToSplit(Item.CenterPoint, refPoint);
                }
                for (int i = 0; i < TVTextList.Count; i++)
                {
                    MixedCAD_Text Item = (MixedCAD_Text)ConvertUtils.DeepCopyObject(TVTextList[i]);
                    CalPointTransToSplit(Item.PositionPoint, refPoint);
                    CalPointTransToSplit(Item.BlockRefPosition, refPoint);
                }
            }
        }

        //获取识别需要的辅助信息 param CadLineList 全量线段数据
        public AssAddAuxInfo GetAssAddAuxInfo()
        {
            AssAddAuxInfo info = new AssAddAuxInfo();
            List<MixedHoleInfo> mixedTopHoleInfoList = RecognizeUtils.CollectionMixHoleInfo();
            //投影图横线List 收集投影图板线X的疑似坐标
            List<FullInfoLine> tempTopViewTLineList = new List<FullInfoLine>();
            foreach (KeyValuePair<double, List<FullInfoLine>> kvp in RecognizeUtils.WholeTopViewData.TransverseLineDic)
                foreach (var item in kvp.Value)
                    tempTopViewTLineList.Add(item);
            //投影图 板宽边界Y
            double TopViewStartY = Math.Round(tempTopViewTLineList.Max(item => item.StartPoint.CustomerPoint.Y), 0);
            double TopViewEndY = Math.Round(tempTopViewTLineList.Min(item => item.StartPoint.CustomerPoint.Y), 0);
            //投影图板X范围长度参考值
            double refTTLineLength = Math.Round(TopViewStartY - TopViewEndY, 0);
            double TopViewTransLineMLLength = tempTopViewTLineList.Max(item => item.RealLength);
            //从投影图收集过来的板线候选X坐标(竖)
            List<double> FTVBoardXList = new List<double>();
            //投影图 和板长一样长度的板线(竖)
            List<FullInfoLine> FTVAsLongLengthList = new List<FullInfoLine>();
            foreach (KeyValuePair<double, List<FullInfoLine>> kvp in RecognizeUtils.WholeTopViewData.VerticalLineDic)
            {
                //暂不考虑直线断线 
                foreach (var item in kvp.Value)
                {
                    //虚 竖线 带倒角(长度会变小) 实线长度可能会超出
                    if (refTTLineLength - 10 <= Math.Round(item.RealLength, 0) ||
                        Math.Round(item.RealLength, 0) >= refTTLineLength)
                    {
                        FTVBoardXList.Add(item.StartPoint.CustomerPoint.X);
                        FTVAsLongLengthList.Add(item);
                    }
                }
            }
            FTVBoardXList = FTVBoardXList.OrderBy(item => item).ToList();
            //I型(工字)
            List<string> IShapedCodeList = new List<string>() { "SAI", "SBI", "SCI", "SDI", "DAI", "DBI",
                "DCI", "DDI", "EAI", "EBI", "ECI", "EDI", "FAI", "FCI", "GAI", "GCI" };
            Boolean IShapedF = IShapedCodeList.Contains(CADCommonForm.CategoryStr);
            info.IShapedF = IShapedF;
            info.FTVBoardXList = FTVBoardXList;
            info.mixedTopHoleInfoList = mixedTopHoleInfoList;
            return info;
        }

        //收集后续组装图组成横板线需要过滤的横线段
        public static List<MixedCAD_Line> CollectionFilterComposedHorLine(List<MixedCAD_Line> TLineList, List<MixedHoleInfo> mixHoleInfoList)
        {
            List<MixedCAD_Line> resList = (List<MixedCAD_Line>)ConvertUtils.DeepCopyObject(TLineList);
            double? refLength = null;
            if (mixHoleInfoList.Count > 0)
            {
                List<double> allDimList = new List<double>();
                for (int i = 0; i < mixHoleInfoList.Count; i++)
                    allDimList.AddRange(mixHoleInfoList[i].DimList);
                refLength = allDimList.Max(item => item) + 5;
            }
            if (mixHoleInfoList.Count > 0 && resList.Count > 0)
            {
                for (int i = 0; i < mixHoleInfoList.Count; i++)
                {
                    for (int j = 0; j < resList.Count; j++)
                    {
                        double mixholeItemX = mixHoleInfoList[i].CenterPoint.CustomerPoint.X;
                        double agvTX = (resList[j].StartPoint.CustomerPoint.X + resList[j].EndPoint.CustomerPoint.X) / 2;
                        Boolean F1 = agvTX - 0.2 <= mixholeItemX && mixholeItemX <= agvTX + 0.2;
                        //横线关于圆心X中心对称
                        if (F1)
                        {
                            Boolean F2 = resList[j].Length <= (double)refLength;
                            if (F2)
                            {
                                resList.RemoveAt(j);
                                j++;
                            }
                        }
                    }
                }
            }
            return resList;
        }

        //判断 横线  斜线(倒角)末端是否相连(误差在两公分内)
        public static LineJoinType JudgeTOLineConn(MixedCAD_Line TLine, MixedCAD_Line OBLine)
        {

            Boolean F1 = Math.Round(OBLine.StartPoint.CustomerPoint.X, 0) - 2 <= Math.Round(TLine.StartPoint.CustomerPoint.X, 0)
                && Math.Round(TLine.StartPoint.CustomerPoint.X, 0) <= Math.Round(OBLine.StartPoint.CustomerPoint.X, 0) + 2
                && Math.Round(TLine.StartPoint.CustomerPoint.Y, 0) == Math.Round(OBLine.StartPoint.CustomerPoint.Y, 0);
            if (F1)
                return LineJoinType.FSJoinSS;

            Boolean F2 = Math.Round(OBLine.EndPoint.CustomerPoint.X, 0) - 2 <= Math.Round(TLine.StartPoint.CustomerPoint.X, 0)
                && Math.Round(TLine.StartPoint.CustomerPoint.X, 0) <= Math.Round(OBLine.EndPoint.CustomerPoint.X, 0) + 2
                && Math.Round(TLine.StartPoint.CustomerPoint.Y, 0) == Math.Round(OBLine.EndPoint.CustomerPoint.Y, 0);
            if (F2)
                return LineJoinType.FSJoinSE;

            Boolean F3 = Math.Round(OBLine.StartPoint.CustomerPoint.X, 0) - 2 <= Math.Round(TLine.EndPoint.CustomerPoint.X, 0)
                && Math.Round(TLine.EndPoint.CustomerPoint.X, 0) <= Math.Round(OBLine.StartPoint.CustomerPoint.X, 0) + 2
                && Math.Round(TLine.EndPoint.CustomerPoint.Y, 0) == Math.Round(OBLine.StartPoint.CustomerPoint.Y, 0);
            if (F3)
                return LineJoinType.FEJoinSS;

            Boolean F4 = Math.Round(TLine.EndPoint.CustomerPoint.X, 0) - 2 <= Math.Round(OBLine.EndPoint.CustomerPoint.X, 0)
                && Math.Round(OBLine.EndPoint.CustomerPoint.X, 0) <= Math.Round(TLine.EndPoint.CustomerPoint.X, 0) + 2
                && Math.Round(TLine.EndPoint.CustomerPoint.Y, 0) == Math.Round(OBLine.EndPoint.CustomerPoint.Y, 0);
            if (F4)
                return LineJoinType.FEJoinSE;

            return LineJoinType.None;
        }

        //判断竖线 斜线 末端 是否相连
        public static LineJoinType JudgeVOLineConn(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            if (Math.Round(line1.StartPoint.CustomerPoint.X, 1) == Math.Round(line2.StartPoint.CustomerPoint.X, 1)
                && Math.Round(line1.StartPoint.CustomerPoint.Y, 0) == Math.Round(line2.StartPoint.CustomerPoint.Y, 0))
                return LineJoinType.FSJoinSS;

            if (Math.Round(line1.StartPoint.CustomerPoint.X, 1) == Math.Round(line2.EndPoint.CustomerPoint.X, 1)
                && Math.Round(line1.StartPoint.CustomerPoint.Y, 0) == Math.Round(line2.EndPoint.CustomerPoint.Y, 0))
                return LineJoinType.FSJoinSE;

            if (Math.Round(line1.EndPoint.CustomerPoint.X, 1) == Math.Round(line2.StartPoint.CustomerPoint.X, 1)
                && Math.Round(line1.EndPoint.CustomerPoint.Y, 0) == Math.Round(line2.StartPoint.CustomerPoint.Y, 0))
                return LineJoinType.FEJoinSS;

            if (Math.Round(line1.EndPoint.CustomerPoint.X, 1) == Math.Round(line2.EndPoint.CustomerPoint.X, 1)
                && Math.Round(line1.EndPoint.CustomerPoint.Y, 0) == Math.Round(line2.EndPoint.CustomerPoint.Y, 0))
                return LineJoinType.FEJoinSE;

            return LineJoinType.None;
        }

        //判断两竖线 是否能进行合并
        public static Boolean JudgeTwoVLineCanMerge(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            Boolean Res = false;
            double sx1 = Math.Round(line1.StartPoint.CustomerPoint.X, 2);
            double sx2 = Math.Round(line2.StartPoint.CustomerPoint.X, 2);
            Boolean SameXF = sx1 == sx2;

            double SY1 = line1.StartPoint.CustomerPoint.Y;
            double EY1 = line1.EndPoint.CustomerPoint.Y;
            double SY2 = line2.StartPoint.CustomerPoint.Y;
            double EY2 = line2.EndPoint.CustomerPoint.Y;

            Boolean YF1 = SY1 >= SY2 && SY2 >= EY1;
            Boolean YF2 = SY2 >= SY1 && SY1 >= EY2;
            Boolean ConYF = YF1 || YF2;

            Res = SameXF && ConYF;

            return Res;
        }

        //合并两条 近似X坐标的竖线 (没考虑 竖线中 倒角数据)
        public static MixedCAD_Line MergeTwoSameXVLine(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            MixedCAD_Line Res = new MixedCAD_Line();
            double sy1 = line1.StartPoint.CustomerPoint.Y;
            double sy2 = line2.StartPoint.CustomerPoint.Y;
            double ey1 = line1.EndPoint.CustomerPoint.Y;
            double ey2 = line2.EndPoint.CustomerPoint.Y;
            double newsy = sy1 > sy2 ? sy1 : sy2;
            double newey = ey1 < ey2 ? ey1 : ey2;
            Res.StartPoint.CustomerPoint.X = line1.StartPoint.CustomerPoint.X;
            Res.EndPoint.CustomerPoint.X = line1.StartPoint.CustomerPoint.X;
            
            Res.StartPoint.CustomerPoint.Y = newsy;
            Res.EndPoint.CustomerPoint.Y = newey;
            Res.Length = Res.StartPoint.CustomerPoint.Y - Res.EndPoint.CustomerPoint.Y;

            Res.StartPoint.UsePoint.X = line1.StartPoint.UsePoint.X;
            Res.EndPoint.UsePoint.X = line1.StartPoint.UsePoint.X;

            double usy1 = line1.StartPoint.UsePoint.Y;
            double usy2 = line2.StartPoint.UsePoint.Y;
            double uey1 = line1.EndPoint.UsePoint.Y;
            double uey2 = line2.EndPoint.UsePoint.Y;
            double unewsy = usy1 > usy2 ? usy1 : usy2;
            double unewey = uey1 < uey2 ? uey1 : uey2;
            Res.StartPoint.UsePoint.Y = unewsy;
            Res.EndPoint.UsePoint.Y = unewey;


            return Res;
        }

        public static bool LRCSingleLengthSame(CSinglePartItem Item)
        {
            double RL= Item.RLine.Length;
            double LL =Item.LLine.Length;
            double maxL = RL > LL ? RL : LL; 
            double minL = RL < LL ? RL : LL;
            double diffL = maxL - minL;
            bool Res = minL / 5 - diffL > 0;
            return Res;
        }

        //对竖线集合进行合并操作
        public static List<MixedCAD_Line> MergeSimilarXVLineList(List<MixedCAD_Line> VList)
        {
            CAD_Point CustomRefPoint = AssemblyShareData.AVCCenterInfo.CustomerPoint;
            int num = VList.Count;
            List<MixedCAD_Line> Res = new List<MixedCAD_Line>();
            Boolean[] merged = new bool[num];
            for(int i = 0; i < VList.Count; i++)
            {
                if (merged[i]) continue;
                MixedCAD_Line current = VList[i];
                for(int j = i + 1; j < VList.Count; j++)
                {
                    if (merged[j]) continue;
                    Boolean F = JudgeTwoVLineCanMerge(current, VList[j]);
                    if (F)
                    {
                        current = MergeTwoSameXVLine(current, VList[j]);
                        merged[j] = true;
                    }
                }
                CalLineTransToSplit(current, CustomRefPoint);
                Res.Add(current);
            }
            return Res;
        }

        //全量的零件横线候选集
        public static Dictionary<double, List<MixedCAD_Line>> GetSuitItemDic(List<MixedCAD_Line> CadLineList, AssAddAuxInfo assAddAuxInfo)
        {
            List<MixedCAD_Line> comfrimList = new List<MixedCAD_Line>();
            List<MixedCAD_Line> operList = (List<MixedCAD_Line>)ConvertUtils.DeepCopyObject(CadLineList);
            List<MixedCAD_Line> ItemXLineList = operList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y)
                .ThenBy(item => item.StartPoint.CustomerPoint.X).Where(item => item.LineType == CADLineType.XDirLine).ToList();
            double? refLength = assAddAuxInfo.holeRefLength;
            //double limitConL = AssemTLineConnectLimitL(FTVBoardXList) * 0.6;
            if (refLength != null)
                ItemXLineList = ItemXLineList.FindAll(item => item.Length <= refLength);
            // 以Y坐标作为KEY 收集 零件横线
            Dictionary<double, List<MixedCAD_Line>> ItemTSLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
            for (int i = 0; i < ItemXLineList.Count; i++)
            {
                if (ItemTSLineYDic.ContainsKey(ItemXLineList[i].StartPoint.CustomerPoint.Y))
                {
                    List<MixedCAD_Line> target = ItemTSLineYDic[ItemXLineList[i].StartPoint.CustomerPoint.Y];
                    target.Add(ItemXLineList[i]);
                }
                else
                    ItemTSLineYDic.Add(ItemXLineList[i].StartPoint.CustomerPoint.Y, new List<MixedCAD_Line>() { ItemXLineList[i] });
            }
            List<double> ItemKeysList = ItemTSLineYDic.Keys.ToList();
            for (int i = 0; i < ItemKeysList.Count; i++)
            {
                List<MixedCAD_Line> tempList = ItemTSLineYDic[ItemKeysList[i]];
                if (tempList.Count == 1)
                {
                    MixedCAD_Line temp = tempList.First();
                    comfrimList.Add(temp);
                }
                else
                {
                    tempList = tempList.OrderBy(item => item.StartPoint.CustomerPoint.X).ToList();
                    Boolean ConnF = JudgeInclusionAndLargeInterval(tempList);
                    //满足连接条件
                    if (ConnF)
                    {
                        MixedCAD_Line temp = new MixedCAD_Line();
                        double MinX = tempList.Min(item => item.StartPoint.CustomerPoint.X);
                        double MaxX = tempList.Max(item => item.EndPoint.CustomerPoint.X);
                        MixedCAD_Line LLine = tempList.Find(Item => Item.StartPoint.CustomerPoint.X == MinX);
                        MixedCAD_Line RLine = tempList.FindLast(Item => Item.EndPoint.CustomerPoint.X == MaxX);
                        temp.StartPoint.CustomerPoint.X = LLine.StartPoint.CustomerPoint.X;
                        temp.StartPoint.CustomerPoint.Y = LLine.StartPoint.CustomerPoint.Y;
                        temp.EndPoint.CustomerPoint.X = LLine.EndPoint.CustomerPoint.X;
                        temp.EndPoint.CustomerPoint.Y = LLine.EndPoint.CustomerPoint.Y;
                        temp.LineType = CADLineType.XDirLine;
                        temp.Length = temp.EndPoint.CustomerPoint.X - temp.StartPoint.CustomerPoint.X;
                        comfrimList.Add(temp);
                    }
                    else
                        comfrimList.AddRange(tempList);
                }
            }
            if (comfrimList.Count > 0)
            {
                ItemTSLineYDic.Clear();
                for (int i = 0; i < comfrimList.Count; i++)
                {
                    if (ItemTSLineYDic.ContainsKey(comfrimList[i].StartPoint.CustomerPoint.Y))
                    {
                        List<MixedCAD_Line> target = ItemTSLineYDic[comfrimList[i].StartPoint.CustomerPoint.Y];
                        target.Add(comfrimList[i]);
                    }
                    else
                        ItemTSLineYDic.Add(comfrimList[i].StartPoint.CustomerPoint.Y, new List<MixedCAD_Line>() { comfrimList[i] });
                }
            }
            return ItemTSLineYDic;
        }

        //收集轮廓线策略A(出现moldbase的场景)
        public static ColProInfo ColContourLineTacticsA(List<MixedCAD_Line> CadLineList, AssAddAuxInfo assAddAuxInfo)
        {
            ColProInfo info = new ColProInfo();

            List<MixedCAD_Line> operList = (List<MixedCAD_Line>)ConvertUtils.DeepCopyObject(CadLineList);
            List<MixedCAD_Line> ImXDirLineList = operList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y)
                .ThenBy(item => item.StartPoint.CustomerPoint.X).Where(item => item.LineType == CADLineType.XDirLine).ToList();

            //降序 竖线集合
            List<MixedCAD_Line> ImYDirLineList = operList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y)
                .ThenBy(item => item.StartPoint.CustomerPoint.X).Where(item => item.LineType == CADLineType.YDirLine).ToList();
            //斜线集合
            List<MixedCAD_Line> ImObliqueLineList = operList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y)
                .ThenBy(item => item.StartPoint.CustomerPoint.X).Where(item => item.LineType == CADLineType.ObliqueLine).ToList();

            for (int i = 0; i < ImObliqueLineList.Count; i++)
            {
                //外轮廓横线和倒角关联
                var obItem = ImObliqueLineList[i];
                if (ImObliqueLineList.Count > 0)
                {
                    for (int j = 0; j < ImXDirLineList.Count; j++)
                    {
                        LineJoinType targetType = JudgeTOLineConn(ImXDirLineList[j], obItem);
                        Boolean F = targetType != LineJoinType.None;
                        if (F)
                            AssSegmentTOLineConn(targetType, ImXDirLineList[j], obItem);
                    }
                    for (int j = 0; j < ImYDirLineList.Count; j++)
                    {
                        LineJoinType targetType = JudgeVOLineConn(ImYDirLineList[j], obItem);
                        Boolean F = targetType != LineJoinType.None;
                        if (F)
                            AssSegmentTOLineConn(targetType, ImYDirLineList[j], obItem);
                    }
                }
            }

            // Y Coor KEY Collection XLine TLine
            Dictionary<double, List<MixedCAD_Line>> moldShapeTSLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
            List<MixedCAD_Line> afImXDirLineList = CollectionFilterComposedHorLine(ImXDirLineList, assAddAuxInfo.mixedTopHoleInfoList);

            for (int i = 0; i < afImXDirLineList.Count; i++)
            {
                if (moldShapeTSLineYDic.ContainsKey(afImXDirLineList[i].StartPoint.CustomerPoint.Y))
                {
                    List<MixedCAD_Line> target = moldShapeTSLineYDic[afImXDirLineList[i].StartPoint.CustomerPoint.Y];
                    target.Add(afImXDirLineList[i]);
                }
                else
                    moldShapeTSLineYDic.Add(afImXDirLineList[i].StartPoint.CustomerPoint.Y, new List<MixedCAD_Line>() { afImXDirLineList[i] });
            }
            info.BoardTSLineYDic = moldShapeTSLineYDic;
            // Y Coor KEY Collection YLine YLine
            Dictionary<double, List<MixedCAD_Line>> AVLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
            for (int i = 0; i < ImYDirLineList.Count; i++)
            {
                if (AVLineYDic.ContainsKey(ImYDirLineList[i].StartPoint.CustomerPoint.Y))
                {
                    List<MixedCAD_Line> target = AVLineYDic[ImYDirLineList[i].StartPoint.CustomerPoint.Y];
                    target.Add(ImYDirLineList[i]);
                }
                else
                    AVLineYDic.Add(ImYDirLineList[i].StartPoint.CustomerPoint.Y, new List<MixedCAD_Line>() { ImYDirLineList[i] });
            }
            info.AVLineYDic = AVLineYDic;
            // Y Coor KEY Collection ObLine
            Dictionary<double, List<MixedCAD_Line>> OBLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
            for (int i = 0; i < ImObliqueLineList.Count; i++)
            {
                if (OBLineYDic.ContainsKey(ImObliqueLineList[i].StartPoint.CustomerPoint.Y))
                {
                    List<MixedCAD_Line> target = OBLineYDic[ImObliqueLineList[i].StartPoint.CustomerPoint.Y];
                    target.Add(ImObliqueLineList[i]);
                }
                else
                    OBLineYDic.Add(ImObliqueLineList[i].StartPoint.CustomerPoint.Y, new List<MixedCAD_Line>() { ImObliqueLineList[i] });
            }
            info.OBLineYDic = OBLineYDic;

            return info;
        }

        public static CAD_Color GetTacticsRecommendedColor(CandidateMixInfo judgeInfo)
        {
            CAD_Color partCColor = null;
            //推选出颜色用于辅助策略C
            if (judgeInfo.eachBoardInfo.Count > 0)
            {
                //主颜色I的最后一件 没I S的最后一件
                int iTypeIndex = judgeInfo.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.I);
                if (iTypeIndex != -1)
                {
                    CandidateBLIAboutInfo iTypeAboutInfo = judgeInfo.eachBoardInfo[iTypeIndex];
                    if (iTypeAboutInfo.AboutLList.Count > 0)                    
                    {
                        FullInfoLine ilastLine = iTypeAboutInfo.AboutLList[iTypeAboutInfo.AboutLList.Count - 1];
                        partCColor = ilastLine.MainColorInfo;
                    }
                }
                else
                {
                    int sTypeIndex = judgeInfo.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.S);
                    if (sTypeIndex != -1)
                    {
                        CandidateBLIAboutInfo sTypeAboutInfo = judgeInfo.eachBoardInfo[sTypeIndex];
                        if (sTypeAboutInfo.AboutLList.Count > 0)
                        {
                            FullInfoLine slastLine = sTypeAboutInfo.AboutLList[sTypeAboutInfo.AboutLList.Count - 1];
                            partCColor = slastLine.MainColorInfo;
                        }
                    }
                }
            }
            return partCColor;
        }

        //Assem Connect the board line allocation strategy algorithm 
        public ColProInfo CATLineAllocStrategy(List<MixedCAD_Line> CadLineList, List<MixedCAD_Line> CenterList, AssAddAuxInfo assAddAuxInfo)
        {
            List<FullInfoLine> moldShapeCandTLineList = new List<FullInfoLine>();
            CandidateMixInfo judgeInfo = new CandidateMixInfo();
            List<BoardLineShapeAndNumType> shareNumCaseList = new List<BoardLineShapeAndNumType>();
            CAD_Color partCColor = null;
            ColProInfo resInfo = ColContourLineTacticsA(CadLineList, assAddAuxInfo);

            //Item T Line Info
            Dictionary<double, List<MixedCAD_Line>> ItemDic = GetSuitItemDic(CadLineList, assAddAuxInfo);
            
            //Optimal policy
            List<FullInfoLine> connectTLineList = JoinBoardTLineTacticsPlanBest(resInfo.BoardTSLineYDic, assAddAuxInfo.IShapedF,
                assAddAuxInfo.FTVBoardXList, CenterList);

            judgeInfo = AssemEstStrategy(assAddAuxInfo.IShapedF, connectTLineList, assAddAuxInfo.FTVBoardXList);

            //Strict
            partCColor = GetTacticsRecommendedColor(judgeInfo);
            if(partCColor != null)
            {
                List<FullInfoLine> moldShapeTATLineListB = JoinBoardTLineTacticsStrict(assAddAuxInfo.IShapedF, 
                    assAddAuxInfo.FTVBoardXList, resInfo.BoardTSLineYDic);
                judgeInfo = AssemEstStrategy(assAddAuxInfo.IShapedF, moldShapeTATLineListB, assAddAuxInfo.FTVBoardXList);
                shareNumCaseList = CheckCandidateLineNum(assAddAuxInfo.IShapedF, judgeInfo);
                Boolean case2F = JudgeCheckNumCase(shareNumCaseList);
                if (case2F)
                {
                    resInfo.CandidateTLineList = judgeInfo.GetAllBoardLineList();
                    resInfo.ItemTSLineYDic = ItemDic;
                    return resInfo;
                }
                else
                    RepIrrDrawLineStrategy(assAddAuxInfo, moldShapeTATLineListB, CadLineList);

                //Ref Color
                resInfo = ColContourLineByMainColor(partCColor, CadLineList, assAddAuxInfo);
                List<FullInfoLine> moldShapeTATLineListC = JoinBoardTLineTacticsByColor(resInfo.IShapedF, resInfo.FTVBoardXList, resInfo.BoardTSLineYDic);
                judgeInfo = AssemEstStrategy(assAddAuxInfo.IShapedF, moldShapeTATLineListC, assAddAuxInfo.FTVBoardXList);
                shareNumCaseList = CheckCandidateLineNum(assAddAuxInfo.IShapedF, judgeInfo);
                Boolean case3F = JudgeCheckNumCase(shareNumCaseList);
                if (case3F)
                {
                    resInfo.CandidateTLineList = judgeInfo.GetAllBoardLineList();
                    resInfo.ItemTSLineYDic = ItemDic;
                    return resInfo;
                }

                //Ignore Color
                judgeInfo = AssemEstStrategy(assAddAuxInfo.IShapedF, connectTLineList, assAddAuxInfo.FTVBoardXList);
                shareNumCaseList = CheckCandidateLineNum(assAddAuxInfo.IShapedF, judgeInfo);
                Boolean case4F = JudgeCheckNumCase(shareNumCaseList);
                if (case4F)
                {
                    resInfo.CandidateTLineList = judgeInfo.GetAllBoardLineList();
                    resInfo.ItemTSLineYDic = ItemDic;
                    return resInfo;
                }

            }
            else
            {
                //Loose
                shareNumCaseList = CheckCandidateLineNum(assAddAuxInfo.IShapedF, judgeInfo);
                Boolean caseBestF = JudgeCheckNumCase(shareNumCaseList);
                if (caseBestF) 
                {
                    resInfo.CandidateTLineList = judgeInfo.GetAllBoardLineList();
                    resInfo.ItemTSLineYDic = ItemDic;
                    return resInfo;
                }

                //Not Ideal
                judgeInfo = JoinBoardTLineDWGNotIdeal(assAddAuxInfo.IShapedF,judgeInfo, connectTLineList);
                shareNumCaseList = CheckCandidateLineNum(assAddAuxInfo.IShapedF, judgeInfo);
                caseBestF = JudgeCheckNumCase(shareNumCaseList);
                if (caseBestF)
                {
                    resInfo.CandidateTLineList = judgeInfo.GetAllBoardLineList();
                    resInfo.ItemTSLineYDic = ItemDic;
                    return resInfo;
                }
            }
            resInfo.ItemTSLineYDic = ItemDic;
            return resInfo;
        }

        //TransverseLine limit Connect Length
        public double AssemTLineConnectLimitL(List<double> FTVBoardXList)
        {
            double MaxL = 0;
            List<double> operList = FTVBoardXList.OrderBy(item => item).ToList();
            if(operList.Count > 1)
            {
                for(int i = 0; i < operList.Count -1; i++)
                {
                    int j = i + 1;
                    double tempL = operList[j] - operList[i];
                    MaxL = Math.Max(MaxL, tempL);
                }
            }
            return MaxL;
        }

        public List<FullInfoLine> JoinBoardTLineTacticsPlanBest(Dictionary<double, List<MixedCAD_Line>> TSLineYDic,
            Boolean IShapedF, List<double> FTVBoardXList, List<MixedCAD_Line> CenterList)
        {
            List<FullInfoLine> resList = new List<FullInfoLine>();
            List<MixedHoleInfo> mixedTHoleList = RecognizeUtils.CollectionMixHoleInfo();
            double limitConL = AssemTLineConnectLimitL(FTVBoardXList) * 0.6;
            double compareDim = 0;
            Boolean compareDimF = false;
            List<double> cxList = new List<double>();
            if (CenterList.Count > 0)
                CenterList.ForEach(item => cxList.Add(Math.Round(item.StartPoint.CustomerPoint.X, 1)));
            if (mixedTHoleList.Count > 0 && cxList.Count > 0)
            {
                List<List<double>> DimLList = mixedTHoleList.Select(item => item.DimList).ToList();
                if (DimLList.Count > 0)
                {
                    List<double> allHDimList = new List<double>();
                    DimLList.ForEach(item => allHDimList.AddRange(item));
                    compareDim = allHDimList.Max() + 30;
                    compareDimF = true;
                }
            }
            //flattening
            List<MixedCAD_Line> operList = new List<MixedCAD_Line>();
            if (TSLineYDic.Keys.Count > 0)
                TSLineYDic.Keys.ToList().ForEach(item => operList.AddRange(TSLineYDic[item]));
            //do filter
            if (operList.Count > 0)
            {
                //use centerLine exclude disturb
                if (cxList.Count > 0)
                {
                    for (int i = 0; i < cxList.Count; i++)
                    {
                        for (int j = 0; j < operList.Count; j++)
                        {
                            double lineCX = Math.Round((operList[j].StartPoint.CustomerPoint.X + operList[j].EndPoint.CustomerPoint.X) / 2, 1);
                            if (lineCX == cxList[i])
                            {
                                //struct limit
                                if (compareDimF)
                                {
                                    if (operList[j].Length <= compareDim)
                                    {
                                        operList.RemoveAt(j);
                                        j--;
                                    }
                                }
                                //loose limit
                                else
                                {
                                    operList.RemoveAt(j);
                                    j--;
                                }
                            }
                        }
                    }
                }
            }
            // anew tissue Dic
            Dictionary<double, List<MixedCAD_Line>> operYDic = new Dictionary<double, List<MixedCAD_Line>>();

            if (operList.Count > 0)
            {
                operList = operList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y).ToList();
                for (int i = 0; i < operList.Count; i++)
                {
                    double keyY = operList[i].StartPoint.CustomerPoint.Y;
                    if (operYDic.ContainsKey(keyY))
                        operYDic[keyY].Add(operList[i]);
                    else
                        operYDic.Add(keyY, new List<MixedCAD_Line>() { operList[i] });
                }
                operList.Clear();
            }

            if (operYDic.Keys.Count > 0)
            {
                Boolean continueScanPPF = true;
                double scanMaxY = operYDic.Keys.Min() + 80;
                double scanMinY = operYDic.Keys.Min() + 35;
                double epfpRecNum = operYDic.Keys.Count * 0.6;
                Dictionary<double, FullInfoLine> moldShapeTATLineDic = new Dictionary<double, FullInfoLine>();
                //Same Length with TV Board
                List<FullInfoLine> FTVAsLongLengthList = new List<FullInfoLine>();
                PatternPitInfo PPL = new PatternPitInfo();
                PatternPitInfo PPR = new PatternPitInfo();
                //For Process H mold  Pattern pit  appearance
                if (FTVBoardXList.Count >= 4 && !IShapedF)
                {
                    double PatternPitL = FTVBoardXList[1] - FTVBoardXList[0];
                    double PatternPitR = FTVBoardXList[FTVBoardXList.Count - 1] - FTVBoardXList[FTVBoardXList.Count - 2];
                    PPL.boundaryX = FTVBoardXList[0];
                    PPL.length = PatternPitL;
                    PPL.BType = FPosType.L;
                    PPR.boundaryX = FTVBoardXList[FTVBoardXList.Count - 1];
                    PPR.length = PatternPitR;
                    PPR.BType = FPosType.R;
                }
                Boolean PPF = PPL.BType != FPosType.NONE && PPR.BType != FPosType.NONE;
                List<double> keysList = operYDic.Keys.ToList();
                //KEY Y
                for (int ki = 0; ki < keysList.Count; ki++)
                {
                    List<MixedCAD_Line> tempList = (List<MixedCAD_Line>)ConvertUtils.DeepCopyObject(operYDic[keysList[ki]]);
                    tempList = tempList.FindAll(item => !item.IsBlockEleFlag);
                    //keep scan
                    if (continueScanPPF)
                    {
                        //cinclude scan target scope
                        Boolean ScanYF = scanMinY <= keysList[ki] && keysList[ki] <= scanMaxY;
                        if (ScanYF)
                        {
                            if (!IShapedF && PPF)
                            {
                                List<MixedCAD_Line> tempSaveList = tempList.FindAll(item => !FilterPatternPitDisLine(item, PPL, PPR));
                                if (tempSaveList.Count != tempList.Count)
                                {
                                    tempList = tempSaveList;
                                    continueScanPPF = false; //stop scan Flag
                                }
                            }
                        }
                    }
                    if (tempList.Count > 0)
                    {
                        FullInfoLine tempHT = new FullInfoLine();
                        if (tempList.Count == 1)
                        {
                            MixedCAD_Line temp = tempList.First();
                            tempHT.RealLength = temp.Length;
                            tempHT.StartPoint = temp.StartPoint;
                            tempHT.EndPoint = temp.EndPoint;
                            tempHT.MainLayer = temp.LayerName;
                            tempHT.MainColorInfo.ColorIndex = temp.ColorInfo.ColorIndex;
                            tempHT.MainColorInfo.ColorNameForDisplay = temp.ColorInfo.ColorNameForDisplay;
                            if (temp.SPChamferFlag)
                            {
                                tempHT.RealLength += Math.Abs(temp.SCLine.StartPoint.CustomerPoint.X - temp.SCLine.EndPoint.CustomerPoint.X);
                                tempHT.StartPoint.CustomerPoint.X -= Math.Abs(temp.SCLine.StartPoint.CustomerPoint.X - temp.SCLine.EndPoint.CustomerPoint.X);
                            }
                            if (temp.EPChamferFlag)
                            {
                                tempHT.RealLength += Math.Abs(temp.ECLine.StartPoint.CustomerPoint.X - temp.ECLine.EndPoint.CustomerPoint.X);
                                tempHT.EndPoint.CustomerPoint.X += Math.Abs(temp.ECLine.StartPoint.CustomerPoint.X - temp.ECLine.EndPoint.CustomerPoint.X);
                            }
                        }
                        else
                        {
                            tempList = tempList.OrderBy(item => item.StartPoint.CustomerPoint.X).ToList();
                            Boolean ConnF = JudgeInclusionAndLargeInterval(tempList, limitConL);
                            if (ConnF)
                            {
                                double MinX = tempList.Min(item => item.StartPoint.CustomerPoint.X);
                                double MaxX = tempList.Max(item => item.EndPoint.CustomerPoint.X);
                                double MastL = tempList.Max(item => item.Length);
                                MixedCAD_Line mainColorL = tempList.Find(item => item.Length == MastL);
                                MixedCAD_Line LLine = tempList.Find(Item => Item.StartPoint.CustomerPoint.X == MinX);
                                MixedCAD_Line RLine = tempList.FindLast(Item => Item.EndPoint.CustomerPoint.X == MaxX);
                                //Best Color
                                if (mainColorL != null)
                                {
                                    tempHT.MainLayer = mainColorL.LayerName;
                                    tempHT.MainColorInfo.ColorIndex = mainColorL.ColorInfo.ColorIndex;
                                    tempHT.MainColorInfo.ColorNameForDisplay = mainColorL.ColorInfo.ColorNameForDisplay;
                                }
                                tempHT.StartPoint = LLine.StartPoint;
                                tempHT.EndPoint = RLine.EndPoint;
                                double tempLength = Math.Abs(tempHT.EndPoint.CustomerPoint.X - tempHT.StartPoint.CustomerPoint.X);
                                if (LLine.SPChamferFlag)
                                {
                                    tempLength += Math.Abs(LLine.SCLine.StartPoint.CustomerPoint.X - LLine.SCLine.EndPoint.CustomerPoint.X);
                                    tempHT.StartPoint.CustomerPoint.X -= Math.Abs(LLine.SCLine.StartPoint.CustomerPoint.X - LLine.SCLine.EndPoint.CustomerPoint.X);
                                }
                                if (RLine.EPChamferFlag)
                                {
                                    tempLength += Math.Abs(RLine.ECLine.StartPoint.CustomerPoint.X - RLine.ECLine.EndPoint.CustomerPoint.X);
                                    tempHT.EndPoint.CustomerPoint.X += Math.Abs(RLine.ECLine.StartPoint.CustomerPoint.X - RLine.ECLine.EndPoint.CustomerPoint.X);
                                }
                                tempHT.RealLength = tempLength;
                            }
                        }
                        //Collection
                        if (moldShapeTATLineDic.ContainsKey(keysList[ki]))
                            moldShapeTATLineDic[keysList[ki]] = tempHT;
                        else
                            moldShapeTATLineDic.Add(keysList[ki], tempHT);
                    }

                }

                foreach (var key in moldShapeTATLineDic.Keys)
                    resList.Add(moldShapeTATLineDic[key]);
            }
            return resList;
        }

        //The interval exceeds a certain range (interval reference value)
        public List<FullInfoLine> JoinBoardTLineTacticsStrict(Boolean IShapedF, List<double> FTVBoardXList, Dictionary<double, List<MixedCAD_Line>> TSLineYDic)
        {
            List<FullInfoLine> ResList = new List<FullInfoLine>();
            List<MixedHoleInfo> mixedTopHoleInfoList = RecognizeUtils.CollectionMixHoleInfo();
            //间隔参考值
            double? intervalRefLength = null;
            if (mixedTopHoleInfoList.Count > 0)
            {
                List<double> allDimList = new List<double>();
                for (int i = 0; i < mixedTopHoleInfoList.Count; i++)
                    allDimList.AddRange(mixedTopHoleInfoList[i].DimList);
                intervalRefLength = allDimList.Max(item => item) + 5;
            }

            if (intervalRefLength != null)
            {
                if (TSLineYDic.Keys.Count > 0)
                {
                    Boolean continueScanPPF = true;
                    double scanMaxY = TSLineYDic.Keys.Min() + 80;
                    double scanMinY = TSLineYDic.Keys.Min() + 35;
                    double epfpRecNum = TSLineYDic.Keys.Count * 0.6;
                    Dictionary<double, FullInfoLine> moldShapeTATLineDic = new Dictionary<double, FullInfoLine>();
                    //投影图 和板长一样长度的板线(竖)
                    List<FullInfoLine> FTVAsLongLengthList = new List<FullInfoLine>();
                    PatternPitInfo PPL = new PatternPitInfo();
                    PatternPitInfo PPR = new PatternPitInfo();
                    //一般H型才出现码模坑 且 码模坑一般在最左右两侧
                    if (FTVBoardXList.Count >= 4 && !IShapedF)
                    {
                        double PatternPitL = FTVBoardXList[1] - FTVBoardXList[0];
                        double PatternPitR = FTVBoardXList[FTVBoardXList.Count - 1] - FTVBoardXList[FTVBoardXList.Count - 2];
                        PPL.boundaryX = FTVBoardXList[0];
                        PPL.length = PatternPitL;
                        PPL.BType = FPosType.L;
                        PPR.boundaryX = FTVBoardXList[FTVBoardXList.Count - 1];
                        PPR.length = PatternPitR;
                        PPR.BType = FPosType.R;
                    }
                    Boolean PPF = PPL.BType != FPosType.NONE && PPR.BType != FPosType.NONE;
                    List<double> keysList = TSLineYDic.Keys.ToList();
                    //KEY Y坐标 VALUE 线段集合
                    for (int ki = 0; ki < keysList.Count; ki++)
                    {
                        List<MixedCAD_Line> tempList = (List<MixedCAD_Line>)ConvertUtils.DeepCopyObject(TSLineYDic[keysList[ki]]);
                        tempList = tempList.FindAll(item => !item.IsBlockEleFlag);
                        if (continueScanPPF)
                        {
                            //在目标扫描Y范围内
                            Boolean ScanYF = scanMinY <= keysList[ki] && keysList[ki] <= scanMaxY;
                            if (ScanYF)
                            {
                                if (!IShapedF && PPF)
                                {
                                    List<MixedCAD_Line> tempSaveList = tempList.FindAll(item => !FilterPatternPitDisLine(item, PPL, PPR));
                                    if (tempSaveList.Count != tempList.Count)
                                    {
                                        tempList = tempSaveList;
                                        continueScanPPF = false;
                                    }
                                }
                            }
                        }
                        if (tempList.Count > 0)
                        {
                            FullInfoLine tempHT = new FullInfoLine();
                            if (tempList.Count == 1)
                            {
                                MixedCAD_Line temp = tempList.First();
                                tempHT.RealLength = temp.Length;

                                tempHT.StartPoint = temp.StartPoint;
                                tempHT.EndPoint = temp.EndPoint;
                                if (temp.SPChamferFlag)
                                {
                                    tempHT.RealLength += Math.Abs(temp.SCLine.StartPoint.CustomerPoint.X - temp.SCLine.EndPoint.CustomerPoint.X);
                                    tempHT.StartPoint.CustomerPoint.X -= Math.Abs(temp.SCLine.StartPoint.CustomerPoint.X - temp.SCLine.EndPoint.CustomerPoint.X);
                                }
                                if (temp.EPChamferFlag)
                                {
                                    tempHT.RealLength += Math.Abs(temp.ECLine.StartPoint.CustomerPoint.X - temp.ECLine.EndPoint.CustomerPoint.X);
                                    tempHT.EndPoint.CustomerPoint.X += Math.Abs(temp.ECLine.StartPoint.CustomerPoint.X - temp.ECLine.EndPoint.CustomerPoint.X);
                                }

                                tempHT.MainLayer = temp.LayerName;
                                tempHT.MainColorInfo.ColorIndex = temp.ColorInfo.ColorIndex;
                                tempHT.MainColorInfo.ColorNameForDisplay = temp.ColorInfo.ColorNameForDisplay;
                            }
                            else
                            {
                                //默认针板在比较靠后的位置(针对于针板线)
                                if (ki > epfpRecNum)
                                {
                                    List<MixedCAD_Line> finalCollectionLList = new List<MixedCAD_Line>();
                                    //用客图的线段颜色先进行一次区分(小概率针板线段和其它零件的线段混在一起)
                                    List<string> colorNFDList = tempList.Select(item => item.ColorInfo.ColorNameForDisplay).Distinct().ToList();
                                    //当不止一种颜色
                                    if (colorNFDList.Count > 0)
                                    {
                                        Dictionary<string, List<MixedCAD_Line>> layerDic = new Dictionary<string, List<MixedCAD_Line>>();
                                        for (int coi = 0; coi < tempList.Count; coi++)
                                        {
                                            if (layerDic.ContainsKey(tempList[coi].LayerName))
                                            {
                                                List<MixedCAD_Line> target = layerDic[tempList[coi].LayerName];
                                                target.Add(tempList[coi]);
                                            }
                                            else
                                                layerDic.Add(tempList[coi].LayerName, new List<MixedCAD_Line>() { tempList[coi] });
                                        }
                                        //确定最长线的图层 去收集相关的图层
                                        double epcL = tempList.Max(item => item.Length);
                                        string epC = tempList.Find(item => item.Length == epcL).LayerName;
                                        finalCollectionLList = layerDic[epC];
                                        //假如里面不是随层 要把随层加上
                                        Boolean layerF1 = finalCollectionLList.Select(item => item.LayerName).ToList().Contains("BYLAYER");
                                        if (!layerF1)
                                        {
                                            List<string> layerNameList = layerDic.Keys.ToList();
                                            if (layerNameList.Contains("BYLAYER"))
                                                finalCollectionLList.AddRange(layerDic["BYLAYER"]);
                                        }
                                    }
                                    //if是modeBase图层的 就忽略颜色问题
                                    List<MixedCAD_Line> moldBaseLineList = tempList.FindAll(item => item.LayerName.Equals("moldbase") || item.LayerName.Equals("Moldbase")).ToList();
                                    if (moldBaseLineList.Count > 0)
                                    {
                                        finalCollectionLList.AddRange(moldBaseLineList);
                                        finalCollectionLList = finalCollectionLList.Distinct(new MixedCADLineEQComparer()).ToList();
                                    }
                                    tempList = finalCollectionLList;
                                }

                                //在前一个判断的时候 可能会导致tempList数量发生变化
                                if (tempList.Count > 1)
                                {
                                    //分段相连的集合
                                    List<MixedCAD_Line> subLList = new List<MixedCAD_Line>();
                                    tempList = tempList.OrderBy(item => item.StartPoint.CustomerPoint.X).ToList();
                                    //正在操作的起始线段 将第一个加入
                                    MixedCAD_Line operBeginLine = (MixedCAD_Line)ConvertUtils.DeepCopyObject(tempList[0]);
                                    subLList.Add(operBeginLine);
                                    //排掉第一条
                                    tempList.RemoveAt(0);
                                    for (int i = 0; i < tempList.Count; i++)
                                    {
                                        //判断是否两条线是否为包含关系
                                        Boolean cloudF = false;
                                        Boolean LSeqF = operBeginLine.Length <= tempList[i].Length;
                                        if (LSeqF)
                                            cloudF = JudgeLLineContainSLine(operBeginLine, tempList[i]);
                                        else
                                            cloudF = JudgeLLineContainSLine(tempList[i], operBeginLine);
                                        //包含 将operBeginLine 置为长线
                                        if (cloudF)
                                        {
                                            if (LSeqF)
                                                operBeginLine = (MixedCAD_Line)ConvertUtils.DeepCopyObject(tempList[i]);
                                        }
                                        else
                                        {
                                            double intervalXLength = tempList[i].StartPoint.CustomerPoint.X - operBeginLine.EndPoint.CustomerPoint.X;
                                            //判断是否满足连接关系 (距离&连接的两端都不存在倒角)
                                            Boolean conF1 = intervalXLength <= (double)intervalRefLength;
                                            Boolean conF2 = !(tempList[i].SPChamferFlag || operBeginLine.EPChamferFlag);
                                            if (conF1 && conF2)
                                            {
                                                operBeginLine.EndPoint.CustomerPoint.X = tempList[i].EndPoint.CustomerPoint.X;
                                                operBeginLine.EPChamferFlag = tempList[i].EPChamferFlag;
                                                operBeginLine.ECLine = tempList[i].ECLine;
                                                operBeginLine.Length = operBeginLine.EndPoint.CustomerPoint.X - operBeginLine.StartPoint.CustomerPoint.X;

                                            }
                                            //不满足 加入分段区间线段集合 并重置operBeginLine为新的起点线段 
                                            else
                                            {
                                                MixedCAD_Line Item = (MixedCAD_Line)ConvertUtils.DeepCopyObject(tempList[i]);
                                                subLList.Add(Item);
                                                operBeginLine = (MixedCAD_Line)ConvertUtils.DeepCopyObject(tempList[i]);
                                            }
                                        }

                                    }
                                    if (subLList.Count > 0)
                                    {
                                        double maxL = subLList.Select(item => item.Length).Max();
                                        MixedCAD_Line comfirmLine = subLList.Find(item => item.Length == maxL);
                                        tempHT.StartPoint = comfirmLine.StartPoint;
                                        tempHT.EndPoint = comfirmLine.EndPoint;
                                        tempHT.RealLength = comfirmLine.Length;
                                        //只有一条 末端倒角 EDIT
                                        if (comfirmLine.SPChamferFlag)
                                        {
                                            tempHT.RealLength += Math.Abs(comfirmLine.SCLine.StartPoint.CustomerPoint.X - comfirmLine.SCLine.EndPoint.CustomerPoint.X);
                                            tempHT.StartPoint.CustomerPoint.X -= Math.Abs(comfirmLine.SCLine.StartPoint.CustomerPoint.X - comfirmLine.SCLine.EndPoint.CustomerPoint.X);
                                        }
                                        if (comfirmLine.EPChamferFlag)
                                        {
                                            tempHT.RealLength += Math.Abs(comfirmLine.ECLine.StartPoint.CustomerPoint.X - comfirmLine.ECLine.EndPoint.CustomerPoint.X);
                                            tempHT.EndPoint.CustomerPoint.X += Math.Abs(comfirmLine.ECLine.StartPoint.CustomerPoint.X - comfirmLine.ECLine.EndPoint.CustomerPoint.X);
                                        }
                                        tempHT.MainLayer = comfirmLine.LayerName;
                                        tempHT.MainColorInfo.ColorIndex = comfirmLine.ColorInfo.ColorIndex;
                                        tempHT.MainColorInfo.ColorNameForDisplay = comfirmLine.ColorInfo.ColorNameForDisplay;
                                    }

                                }

                            }
                            //收集
                            if (moldShapeTATLineDic.ContainsKey(keysList[ki]))
                                moldShapeTATLineDic[keysList[ki]] = tempHT;
                            else
                                moldShapeTATLineDic.Add(keysList[ki], tempHT);
                        }
                    }

                    foreach (var key in moldShapeTATLineDic.Keys)
                        ResList.Add(moldShapeTATLineDic[key]);
                }
            }
            return ResList;
        }

        //The Cusmer DWG Is Not Ideal
        public CandidateMixInfo JoinBoardTLineDWGNotIdeal(Boolean IShapedF,CandidateMixInfo compareRes, List<FullInfoLine> refInfo)
        {
            CandidateMixInfo Res = (CandidateMixInfo)DeepCopyObject(compareRes);
            List<FullInfoLine> RepList = new List<FullInfoLine>();
            List<BoardLineShapeAndNumType> shapeLCList =  CheckCandidateLineNum(IShapedF, compareRes);
            int IShapeIndex = shapeLCList.FindIndex(item => item.shapeType == MoldLineShareType.I);
            int SShapeIndex = shapeLCList.FindIndex(item => item.shapeType == MoldLineShareType.S);
            int EPFPShapeIndex = shapeLCList.FindIndex(item => item.shapeType == MoldLineShareType.EPFP);
            CandidateLineNumType IShapelineNumCase = CandidateLineNumType.NONE;
            CandidateLineNumType SShapelineNumCase = CandidateLineNumType.NONE;
            CandidateLineNumType EPFPShapelineNumCase = CandidateLineNumType.NONE;
            if (IShapeIndex != -1)
                IShapelineNumCase = shapeLCList[IShapeIndex].lineNumType;
            if (SShapeIndex != -1)
                SShapelineNumCase = shapeLCList[SShapeIndex].lineNumType;
            if (EPFPShapeIndex != -1)
                EPFPShapelineNumCase = shapeLCList[EPFPShapeIndex].lineNumType;

            Boolean epfpShapeLessF = EPFPShapelineNumCase == CandidateLineNumType.LESS;
            Boolean IShapeLessF = IShapelineNumCase == CandidateLineNumType.LESS;
            Boolean SShapeLessF = SShapelineNumCase == CandidateLineNumType.LESS;

            //Scene Only For I Less 
            if (IShapeLessF)
            {
                int resIExistF = Res.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.I);
                int resSExistF = Res.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.S);
                int resepfpExistF = Res.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.EPFP);
                Boolean SShapeComformF = SShapelineNumCase == CandidateLineNumType.CONFORM;
                Boolean EPFPShapeComformF = EPFPShapelineNumCase == CandidateLineNumType.CONFORM;
                if (resIExistF != -1 && SShapeComformF && EPFPShapeComformF)
                {
                    List<FullInfoLine> targetSList = Res.eachBoardInfo[resSExistF].AboutLList;
                    List<FullInfoLine> wantTempList = new List<FullInfoLine>();
                    int SFirstIndex = (int)Res.eachBoardInfo[resSExistF].FirstIndex;
                    int epfpLastIndex = (int)Res.eachBoardInfo[resepfpExistF].LastIndex;
                    for(int i = 0; i < refInfo.Count; i++)
                    {
                        Boolean F1 = i < SFirstIndex;
                        Boolean F2 = i > epfpLastIndex;
                        if(F1 || F2)
                            wantTempList.Add(refInfo[i]);
                    }
                    Res.eachBoardInfo[resIExistF].AboutLList = wantTempList;
                }
            }

            //Scene Only For epfp Less
            if (epfpShapeLessF)
            {
                Boolean SShapeComformF = SShapelineNumCase == CandidateLineNumType.CONFORM;
                if (IShapedF)
                {
                    if (SShapeComformF)
                    {
                        int resepfpExistF = Res.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.EPFP);
                        int StargetresIndex = Res.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.S);
                        if (StargetresIndex != -1)
                        {
                            CandidateBLIAboutInfo ScanInfoList = Res.eachBoardInfo[StargetresIndex];
                            double SL = (double)ScanInfoList.Length;
                            FullInfoLine lastSLine = refInfo[(int)ScanInfoList.LastIndex];
                            int beforeepfpIndex = (int)ScanInfoList.LastIndex;
                            List<FullInfoLine> wantTempList = new List<FullInfoLine>();
                            for (int i = beforeepfpIndex + 1; i < refInfo.Count; i++)
                            {
                                Boolean fitLengthF = refInfo[i].RealLength < SL;
                                if (fitLengthF)
                                    wantTempList.Add(refInfo[i]);
                            }
                            if (resepfpExistF != -1)
                                Res.eachBoardInfo[resepfpExistF].AboutLList = wantTempList;
                            else
                            {
                                CandidateBLIAboutInfo epfpAboutInfo = new CandidateBLIAboutInfo();
                                epfpAboutInfo.SType = BoardShapeType.EPFP;
                                epfpAboutInfo.AboutLList = wantTempList;
                                Res.eachBoardInfo.Add(epfpAboutInfo);
                            }
                        }
                    }
                }
                else
                {
                    if (SShapeComformF)
                    {
                        //Count backwards Second Third
                        int StargetresIndex = Res.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.S);
                        if (StargetresIndex != -1)
                        {
                            List<FullInfoLine> SAboutInfoList = Res.eachBoardInfo[StargetresIndex].AboutLList;
                            double SL = (double)Res.eachBoardInfo[StargetresIndex].Length;
                            if (SAboutInfoList.Count - 3 > 0)
                            {
                                FullInfoLine orvepepfpLine = SAboutInfoList[SAboutInfoList.Count - 2];
                                FullInfoLine underepfpLine = SAboutInfoList[SAboutInfoList.Count - 3];
                                double overepfpY = orvepepfpLine.StartPoint.CustomerPoint.Y;
                                double underepfpY = underepfpLine.StartPoint.CustomerPoint.Y;

                                List<FullInfoLine> wantTempList = refInfo.FindAll(item => underepfpY < item.StartPoint.CustomerPoint.Y && item.StartPoint.CustomerPoint.Y < overepfpY);
                                if(wantTempList.Count > 0)
                                {
                                    wantTempList = wantTempList.FindAll(item => item.RealLength < SL);
                                    if(wantTempList.Count > 0)
                                    {
                                        int resepfpExistF = Res.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.EPFP);
                                        if (resepfpExistF != -1)
                                            Res.eachBoardInfo[resepfpExistF].AboutLList = wantTempList;
                                        else
                                        {
                                            CandidateBLIAboutInfo epfpAboutInfo = new CandidateBLIAboutInfo();
                                            epfpAboutInfo.SType = BoardShapeType.EPFP;
                                            epfpAboutInfo.AboutLList = wantTempList;
                                            Res.eachBoardInfo.Add(epfpAboutInfo);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Scene Only For S Less
            if (SShapeLessF)
            {
                if (IShapedF)
                {
                    int resSExistF = Res.eachBoardInfo.FindIndex(item => item.SType == BoardShapeType.S);
                    if(resSExistF != -1)
                    {
                        List<FullInfoLine> SAboutLList = Res.eachBoardInfo[resSExistF].AboutLList;
                        double SL = (double)Res.eachBoardInfo[resSExistF].Length;
                        //Find StartPointX Or EndPointX Same 
                        if (SAboutLList.Count > 0)
                        {
                            List<FullInfoLine> wantTempList = new List<FullInfoLine>();
                            double? SmostSX = null;
                            double? SmostEX = null;
                            if(SAboutLList.Count > 0)
                            {
                                SmostSX = SAboutLList.GroupBy(item => item.StartPoint.CustomerPoint.X) .OrderByDescending(g => g.Count()).First().Key;
                                SmostSX = Math.Round((double)SmostSX, 0);
                                SmostEX = SAboutLList.GroupBy(item => item.EndPoint.CustomerPoint.X) .OrderByDescending(g => g.Count()).First().Key;
                                SmostEX = Math.Round((double)SmostEX, 0);
                            }
                            if (SmostSX != null)
                            {
                                List<FullInfoLine> sceneTempList = refInfo.FindAll(item => Math.Round(item.StartPoint.CustomerPoint.X, 0) == SmostSX).ToList();
                                sceneTempList = sceneTempList.FindAll(item => item.RealLength != SL);
                                if (sceneTempList.Count > 0)
                                    wantTempList.AddRange(sceneTempList);
                            }
                            if (SmostEX != null)
                            {
                                List<FullInfoLine> sceneTempList = refInfo.FindAll(item => Math.Round(item.EndPoint.CustomerPoint.X, 0) == SmostEX).ToList();
                                sceneTempList = sceneTempList.FindAll(item => item.RealLength != SL);
                                if (sceneTempList.Count > 0)
                                    wantTempList.AddRange(sceneTempList);
                            }
                            if (wantTempList.Count > 0)
                                Res.eachBoardInfo[resSExistF].AboutLList.AddRange(wantTempList);
                        }
                    }
                }
            }

            return Res;
        }

        public List<FullInfoLine> JoinBoardTLineTacticsByColor(Boolean IShapedF, List<double> FTVBoardXList, Dictionary<double, List<MixedCAD_Line>> TSLineYDic)
        {
            List<FullInfoLine> resList = new List<FullInfoLine>();
            Dictionary<double, FullInfoLine> moldShapeTATLineDic = new Dictionary<double, FullInfoLine>();
            //投影图 和板长一样长度的板线(竖)
            List<FullInfoLine> FTVAsLongLengthList = new List<FullInfoLine>();
            double limitConL = AssemTLineConnectLimitL(FTVBoardXList) * 0.6;
            PatternPitInfo PPL = new PatternPitInfo();
            PatternPitInfo PPR = new PatternPitInfo();
            //一般H型才出现码模坑 且 码模坑一般在最左右两侧
            if (FTVBoardXList.Count >= 4 && !IShapedF)
            {
                double PatternPitL = FTVBoardXList[1] - FTVBoardXList[0];
                double PatternPitR = FTVBoardXList[FTVBoardXList.Count - 1] - FTVBoardXList[FTVBoardXList.Count - 2];
                PPL.boundaryX = FTVBoardXList[0];
                PPL.length = PatternPitL;
                PPL.BType = FPosType.L;
                PPR.boundaryX = FTVBoardXList[FTVBoardXList.Count - 1];
                PPR.length = PatternPitR;
                PPR.BType = FPosType.R;
            }
            Boolean PPF = PPL.BType != FPosType.NONE && PPR.BType != FPosType.NONE;
            List<double> keysList = TSLineYDic.Keys.ToList();
            //KEY Y坐标 VALUE 线段集合
            for (int ki = 0; ki < keysList.Count; ki++)
            {
                List<MixedCAD_Line> tempList = (List<MixedCAD_Line>)ConvertUtils.DeepCopyObject(TSLineYDic[keysList[ki]]);
                tempList = tempList.FindAll(item => !item.IsBlockEleFlag);
                if (!IShapedF && PPF)
                    tempList = tempList.FindAll(item => !FilterPatternPitDisLine(item, PPL, PPR));

                if (tempList.Count > 0)
                {
                    FullInfoLine tempHT = new FullInfoLine();
                    if (tempList.Count == 1)
                    {
                        MixedCAD_Line temp = tempList.First();
                        tempHT.RealLength = temp.Length;
                        tempHT.StartPoint = temp.StartPoint;
                        tempHT.EndPoint = temp.EndPoint;
                        tempHT.MainLayer = temp.LayerName;
                        tempHT.MainColorInfo.ColorIndex = temp.ColorInfo.ColorIndex;
                        tempHT.MainColorInfo.ColorNameForDisplay = temp.ColorInfo.ColorNameForDisplay;
                        //只有一条 末端倒角
                        if (temp.SPChamferFlag)
                        {
                            tempHT.RealLength += Math.Abs(temp.SCLine.StartPoint.CustomerPoint.X - temp.SCLine.EndPoint.CustomerPoint.X);
                            tempHT.StartPoint.CustomerPoint.X -= Math.Abs(temp.SCLine.StartPoint.CustomerPoint.X - temp.SCLine.EndPoint.CustomerPoint.X);
                        }
                        if (temp.EPChamferFlag)
                        {
                            tempHT.RealLength += Math.Abs(temp.ECLine.StartPoint.CustomerPoint.X - temp.ECLine.EndPoint.CustomerPoint.X);
                            tempHT.EndPoint.CustomerPoint.X += Math.Abs(temp.ECLine.StartPoint.CustomerPoint.X - temp.ECLine.EndPoint.CustomerPoint.X);
                        }
                    }
                    else
                    {
                        tempList = tempList.OrderBy(item => item.StartPoint.CustomerPoint.X).ToList();
                        Boolean ConnF = JudgeInclusionAndLargeInterval(tempList, limitConL);
                        //满足连接条件
                        if (ConnF)
                        {
                            double MinX = tempList.Min(item => item.StartPoint.CustomerPoint.X);
                            double MaxX = tempList.Max(item => item.EndPoint.CustomerPoint.X);
                            double MastL = tempList.Max(item => item.Length);
                            MixedCAD_Line mainColorL = tempList.Find(item => item.Length == MastL);
                            MixedCAD_Line LLine = tempList.Find(Item => Item.StartPoint.CustomerPoint.X == MinX);
                            MixedCAD_Line RLine = tempList.FindLast(Item => Item.EndPoint.CustomerPoint.X == MaxX);
                            //推选最佳颜色
                            if (mainColorL != null)
                            {
                                tempHT.MainLayer = mainColorL.LayerName;
                                tempHT.MainColorInfo.ColorIndex = mainColorL.ColorInfo.ColorIndex;
                                tempHT.MainColorInfo.ColorNameForDisplay = mainColorL.ColorInfo.ColorNameForDisplay;
                            }
                            tempHT.StartPoint = LLine.StartPoint;
                            tempHT.EndPoint = RLine.EndPoint;
                            double tempLength = Math.Abs(tempHT.EndPoint.CustomerPoint.X - tempHT.StartPoint.CustomerPoint.X);
                            if (LLine.SPChamferFlag)
                            {
                                tempLength += Math.Abs(LLine.SCLine.StartPoint.CustomerPoint.X - LLine.SCLine.EndPoint.CustomerPoint.X);
                                tempHT.StartPoint.CustomerPoint.X -= Math.Abs(LLine.SCLine.StartPoint.CustomerPoint.X - LLine.SCLine.EndPoint.CustomerPoint.X);
                            }
                            if (RLine.EPChamferFlag)
                            {
                                tempLength += Math.Abs(RLine.ECLine.StartPoint.CustomerPoint.X - RLine.ECLine.EndPoint.CustomerPoint.X);
                                tempHT.EndPoint.CustomerPoint.X += Math.Abs(RLine.ECLine.StartPoint.CustomerPoint.X - RLine.ECLine.EndPoint.CustomerPoint.X);
                            }
                            tempHT.RealLength = tempLength;
                        }
                    }
                    //收集
                    if (moldShapeTATLineDic.ContainsKey(keysList[ki]))
                        moldShapeTATLineDic[keysList[ki]] = tempHT;
                    else
                        moldShapeTATLineDic.Add(keysList[ki], tempHT);
                }
            }

            foreach (var key in moldShapeTATLineDic.Keys)
                resList.Add(moldShapeTATLineDic[key]);

            return resList;
        }

        //收集策略(颜色区分出主轮廓线段)
        public ColProInfo ColContourLineByMainColor(CAD_Color refColor, List<MixedCAD_Line> CadLineList, AssAddAuxInfo assAddAuxInfo)
        {
            ColProInfo info = new ColProInfo();
            //用颜色过滤
            string refColorIndex = refColor.ColorIndex;
            string refColorDName = refColor.ColorNameForDisplay;
            List<MixedCAD_Line> operList = (List<MixedCAD_Line>)ConvertUtils.DeepCopyObject(CadLineList);
            operList = operList.FindAll(item => item.ColorInfo.ColorNameForDisplay.Equals(refColorDName) && item.ColorInfo.ColorIndex.Equals(refColorIndex));

            List<MixedCAD_Line> ImXDirLineList = operList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y)
                .ThenBy(item => item.StartPoint.CustomerPoint.X).Where(item => item.LineType == CADLineType.XDirLine).ToList();

            List<MixedCAD_Line> ImYDirLineList = CadLineList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y)
                .ThenBy(item => item.StartPoint.CustomerPoint.X).Where(item => item.LineType == CADLineType.YDirLine).ToList();

            List<MixedCAD_Line> ImObliqueLineList = CadLineList.OrderByDescending(item => item.StartPoint.CustomerPoint.Y)
                .ThenBy(item => item.StartPoint.CustomerPoint.X).Where(item => item.LineType == CADLineType.ObliqueLine).ToList();

            for (int i = 0; i < ImObliqueLineList.Count; i++)
            {
                //外轮廓横线和倒角关联
                var obItem = ImObliqueLineList[i];
                if (ImObliqueLineList.Count > 0)
                {
                    for (int j = 0; j < ImXDirLineList.Count; j++)
                    {
                        LineJoinType targetType = JudgeTOLineConn(ImXDirLineList[j], obItem);
                        Boolean F = targetType != LineJoinType.None;
                        if (F)
                            ComputedUtils.AssSegmentTOLineConn(targetType, ImXDirLineList[j], obItem);
                    }
                    for (int j = 0; j < ImYDirLineList.Count; j++)
                    {
                        LineJoinType targetType = JudgeVOLineConn(ImYDirLineList[j], obItem);
                        Boolean F = targetType != LineJoinType.None;
                        if (F)
                            ComputedUtils.AssSegmentTOLineConn(targetType, ImYDirLineList[j], obItem);
                    }
                }
            }

            // 以Y坐标作为KEY 收集 外轮廓横线 Dic
            Dictionary<double, List<MixedCAD_Line>> moldShapeTSLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
            List<MixedCAD_Line> afImXDirLineList = CollectionFilterComposedHorLine(ImXDirLineList, assAddAuxInfo.mixedTopHoleInfoList);
            for (int i = 0; i < afImXDirLineList.Count; i++)
            {
                if (moldShapeTSLineYDic.ContainsKey(afImXDirLineList[i].StartPoint.CustomerPoint.Y))
                {
                    List<MixedCAD_Line> target = moldShapeTSLineYDic[afImXDirLineList[i].StartPoint.CustomerPoint.Y];
                    target.Add(afImXDirLineList[i]);
                }
                else
                    moldShapeTSLineYDic.Add(afImXDirLineList[i].StartPoint.CustomerPoint.Y, new List<MixedCAD_Line>() { afImXDirLineList[i] });
            }
            info.BoardTSLineYDic = moldShapeTSLineYDic;

            // 以Y坐标作为KEY 收集 竖线
            Dictionary<double, List<MixedCAD_Line>> AVLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
            for (int i = 0; i < ImYDirLineList.Count; i++)
            {
                if (AVLineYDic.ContainsKey(ImYDirLineList[i].StartPoint.CustomerPoint.Y))
                {
                    List<MixedCAD_Line> target = AVLineYDic[ImYDirLineList[i].StartPoint.CustomerPoint.Y];
                    target.Add(ImYDirLineList[i]);
                }
                else
                    AVLineYDic.Add(ImYDirLineList[i].StartPoint.CustomerPoint.Y, new List<MixedCAD_Line>() { ImYDirLineList[i] });
            }
            info.AVLineYDic = AVLineYDic;

            // 以Y坐标作为KEY 收集 斜线
            Dictionary<double, List<MixedCAD_Line>> OBLineYDic = new Dictionary<double, List<MixedCAD_Line>>();
            for (int i = 0; i < ImObliqueLineList.Count; i++)
            {
                if (OBLineYDic.ContainsKey(ImObliqueLineList[i].StartPoint.CustomerPoint.Y))
                {
                    List<MixedCAD_Line> target = OBLineYDic[ImObliqueLineList[i].StartPoint.CustomerPoint.Y];
                    target.Add(ImObliqueLineList[i]);
                }
                else
                    OBLineYDic.Add(ImObliqueLineList[i].StartPoint.CustomerPoint.Y, new List<MixedCAD_Line>() { ImObliqueLineList[i] });
            }
            info.OBLineYDic = OBLineYDic;

            return info;
        }

        //关联线段衔接逻辑算法 参数 横竖线 斜线(倒角)
        public static void AssSegmentTOLineConn(LineJoinType targetType, MixedCAD_Line targetLine, MixedCAD_Line obLine)
        {
            switch (targetType)
            {
                //倒角线和直线的连接点顺序待定
                case LineJoinType.FSJoinSS:
                    targetLine.SPChamferFlag = true;
                    MixedCAD_Line FSSSItem = new MixedCAD_Line();
                    FSSSItem.StartPoint = obLine.StartPoint;
                    FSSSItem.EndPoint = obLine.EndPoint;
                    FSSSItem.Length = obLine.Length;
                    targetLine.LayerName = obLine.LayerName;
                    targetLine.SCLine = FSSSItem;
                    break;
                case LineJoinType.FSJoinSE:
                    targetLine.SPChamferFlag = true;
                    MixedCAD_Line FSSEItem = new MixedCAD_Line();
                    FSSEItem.StartPoint = obLine.EndPoint;
                    FSSEItem.EndPoint = obLine.StartPoint;
                    FSSEItem.Length = obLine.Length;
                    targetLine.LayerName = obLine.LayerName;
                    targetLine.SCLine = FSSEItem;
                    break;
                case LineJoinType.FEJoinSS:
                    targetLine.EPChamferFlag = true;
                    MixedCAD_Line FESSItem = new MixedCAD_Line();
                    FESSItem.StartPoint = obLine.StartPoint;
                    FESSItem.EndPoint = obLine.EndPoint;
                    FESSItem.Length = obLine.Length;
                    targetLine.LayerName = obLine.LayerName;
                    targetLine.ECLine = FESSItem;
                    break;
                case LineJoinType.FEJoinSE:
                    targetLine.EPChamferFlag = true;
                    MixedCAD_Line FESEItem = new MixedCAD_Line();
                    FESEItem.StartPoint = obLine.EndPoint;
                    FESEItem.EndPoint = obLine.StartPoint;
                    FESEItem.Length = obLine.Length;
                    targetLine.LayerName = obLine.LayerName;
                    targetLine.ECLine = FESEItem;
                    break;
            }
        }

        //过滤掉可能是码模坑的一些干扰线
        public Boolean FilterPatternPitDisLine(MixedCAD_Line line, PatternPitInfo PPL, PatternPitInfo PPR)
        {
            Boolean SchamferF = line.SPChamferFlag;
            Boolean EchamferF = line.EPChamferFlag;
            //两边都有倒角 默认不是码模坑画法
            if (SchamferF && EchamferF)
                return false;
            else
            {
                double PPLBX = Math.Round(PPL.boundaryX, 1);
                double PPRBX = Math.Round(PPR.boundaryX, 1);
                if (SchamferF && !EchamferF)
                {
                    double SSX = line.SCLine.StartPoint.CustomerPoint.X;
                    double SEX = line.SCLine.EndPoint.CustomerPoint.X;
                    double RealL = line.Length + Math.Abs(SSX - SEX);
                    Boolean CoorF1 = Math.Round(SSX, 1) == PPLBX;
                    Boolean CoorF2 = Math.Round(SEX, 1) == PPLBX;
                    Boolean JF2 = Math.Round(PPL.length, 1) == Math.Round(RealL, 1);
                    return (CoorF1 || CoorF2) && JF2;
                }
                if (!SchamferF && EchamferF)
                {
                    double ESX = line.ECLine.StartPoint.CustomerPoint.X;
                    double EEX = line.ECLine.EndPoint.CustomerPoint.X;
                    double RealL = line.Length + Math.Abs(ESX - EEX);
                    Boolean CoorF1 = Math.Round(ESX, 1) == PPRBX;
                    Boolean CoorF2 = Math.Round(EEX, 1) == PPRBX;
                    Boolean JF2 = Math.Round(PPR.length, 1) == Math.Round(RealL, 1);
                    return (CoorF1 || CoorF2) && JF2;
                }
                else
                {
                    Boolean LLF = Math.Round(PPL.length, 1) == Math.Round(line.Length, 1);
                    Boolean LCoorF = Math.Round(line.StartPoint.CustomerPoint.X, 1) == PPLBX;
                    if (LLF && LCoorF)
                        return true;
                    Boolean RLF = Math.Round(PPR.length, 1) == Math.Round(line.Length, 1);
                    Boolean RCoorF = Math.Round(line.EndPoint.CustomerPoint.X, 1) == PPRBX;
                    if (RLF && RCoorF)
                        return true;
                }
            }
            return false;
        }

        //判断一组横线是否满足相连
        public static Boolean JudgeInclusionAndLargeInterval(List<MixedCAD_Line> OriginList,double limitConnL = 0)
        {
            double CompareLimitL = RecognizeUtils.WholeTopViewData.MostLLength / 5 * 3.89;
            if (limitConnL != 0)
                CompareLimitL = limitConnL;
            List<MixedCAD_Line> tempList = new List<MixedCAD_Line>(OriginList);
            //去除包含线
            tempList = tempList.OrderBy(item => item.Length).ToList();
            for (int i = 0; i < tempList.Count - 1; i++)
            {
                int j = i + 1;
                Boolean F = JudgeLLineContainSLine(tempList[i], tempList[j]);
                if (F)
                {
                    tempList.RemoveAt(i);
                    i++;
                }
            }
            //判断间隔是否过大 > 投影图最长线3/5 默认不相连
            if (tempList.Count > 0)
            {
                //double MaxDic = RecognizeUtils.WholeTopViewData.MostLLength / 5 * 3.89;
                tempList = tempList.OrderBy(item => item.StartPoint.CustomerPoint.X).ToList();
                double MaxL = tempList.Max(item => item.Length);
                //默认接近标准线长度 算进来
                if (MaxL >= CompareLimitL)
                    return true;
                else
                {
                    double Dic = 0;
                    for (int i = 0; i < tempList.Count - 1; i++)
                    {
                        int j = i + 1;
                        Dic = tempList[j].StartPoint.CustomerPoint.X - tempList[i].EndPoint.CustomerPoint.X;
                        if (Dic > CompareLimitL)
                            return false;
                    }
                }
            }
            return true;
        }

        //判断 一条短直线 包含于 一条长直线上
        public static Boolean JudgeLLineContainSLine(MixedCAD_Line ShortLine, MixedCAD_Line LongLine)
        {
            Boolean F1 = Math.Round(LongLine.StartPoint.CustomerPoint.X, 0) <= Math.Round(ShortLine.StartPoint.CustomerPoint.X, 0);
            Boolean F2 = Math.Round(LongLine.EndPoint.CustomerPoint.X, 0) >= Math.Round(ShortLine.EndPoint.CustomerPoint.X, 0);
            return F1 && F2;
        }

        //判断 FullInfoLine 与 CAD_Line 包含关系枚举类型
        public enum FullLineAndLineRangeType
        {
            FULLMORE,//FullInfoLine 包含了 CAD_Line
            LINEMORE,//CAD_Line 包含了 FullInfoLine
            NO //没有包含关系
        }

        //过滤不配对线段((回针)螺丝牙 竖)
        public static Boolean FilterMisMatchToochDimGroupLine(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            double bigL = line1.Length > line2.Length ? line1.Length : line2.Length;
            double smallL = line1.Length < line2.Length ? line1.Length : line2.Length;
            double diffL = bigL * 0.2;
            double line1SY = line1.StartPoint.CustomerPoint.Y;
            double line1EY = line1.EndPoint.CustomerPoint.Y;

            double line2SY = line2.StartPoint.CustomerPoint.Y;
            double line2EY = line2.EndPoint.CustomerPoint.Y;

            Boolean scene1_1 = line2SY <= line1SY;
            Boolean scene1_2 = line2SY > line1EY;
            Boolean scene1_3 = bigL - smallL < diffL;
            if (scene1_1 && scene1_2 && scene1_3)
                return true;

            Boolean scene2_1 = line2SY >= line1SY;
            Boolean scene2_2 = line1SY > line1EY;
            Boolean scene2_3 = bigL - smallL < diffL;
            if (scene2_1 && scene2_2 && scene2_3)
                return true;

            return false;
        }

        //过滤不配对线段(套 竖)
        public static Boolean FilterMismatchBushGroupLine(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            double line1SY = line1.StartPoint.CustomerPoint.Y;
            double line1EY = line1.EndPoint.CustomerPoint.Y;

            double line2SY = line2.StartPoint.CustomerPoint.Y;
            double line2EY = line2.EndPoint.CustomerPoint.Y;

            Boolean scene1_1 = line2SY <= line1SY;
            Boolean scene1_2 = line2EY <= line1EY && line1EY <= line2SY;
            if (scene1_1 && scene1_2)
                return true;

            Boolean scene2_1 = line1EY <= line2EY;
            Boolean scene2_2 = line2EY <= line1SY && line1SY <= line2SY;
            if (scene2_1 && scene2_2)
                return true;

            return false;
        }

        //靠近标准
        public static double RepScrewItemLRule(double L)
        {
            double Res = L;
            Boolean F = L < 160;
            if (F)
            {
                int rem = (int)(L % 10);
                int strip = (int)(L / 10);
                Boolean fiveF1 = 0 < rem && rem < 5;
                Boolean fiveF2 = 5 < rem && rem <= 9;
                if (fiveF1)
                {
                    Boolean F1 = rem == 1 || rem == 2;
                    if (F1)
                        Res = strip * 10;
                    Boolean F2 = rem == 3 || rem == 4;
                    if (F2)
                        Res = strip * 10 + 5;
                }
                if (fiveF2)
                {
                    Boolean F1 = rem <= 7;
                    if (F1)
                        Res = strip * 10 + 5;
                    else
                        Res = (strip + 1) * 10;
                }
            }
            else
            {
                int rem = (int)(L % 10);
                int strip = (int)(L / 10);
                if(rem < 5)
                    Res = strip * 10;
                if (rem > 5)
                    Res = (strip + 1) * 10;
            }
            return Res;
        }

        //非回针 浮动 上下一级 下标 规格集合
        public static void SetNotRPPerNextHoleScope(int MouldIndex, List<int> MouldSizeList)
        {
            Boolean HasFF = AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals("fangtie")) != -1;
            List<StandardHoleData> NoRPHoleList = new List<StandardHoleData>();
            int NowMoldSize = MouldSizeList[MouldIndex];
            NoRPHoleList.AddRange(ParamsConfigData.MoldHoleList.FindAll(item => item.MouldSize == NowMoldSize && !item.Item.Equals("回针")));
            //底板螺丝属于小螺丝 当没有方铁时 底板螺丝的规格=方铁螺丝(大螺丝)
            int SmallScrewDim = 0;
            if (HasFF)
            {
                SmallScrewDim = NoRPHoleList.FindAll(item => item.Item.Equals("小螺丝")).Select(item => item.ItemDim).Distinct().ToList().FirstOrDefault();
                ParamsConfigData.RecommendDimDic.Add("底板螺丝", SmallScrewDim);
            }
            else
            {
                SmallScrewDim = NoRPHoleList.FindAll(item => item.Item.Equals("大螺丝")).Select(item => item.ItemDim).Distinct().ToList().FirstOrDefault();
                ParamsConfigData.RecommendDimDic.Add("底板螺丝", SmallScrewDim);
            }

            int BigScrewDim = NoRPHoleList.FindAll(item => item.Item.Equals("大螺丝")).Select(item => item.ItemDim).Distinct().ToList().FirstOrDefault();
            ParamsConfigData.RecommendDimDic.Add("面板螺丝", BigScrewDim);
            ParamsConfigData.RecommendDimDic.Add("方铁螺丝", BigScrewDim);
            ParamsConfigData.RecommendDimDic.Add("公制螺丝", BigScrewDim);
            int FallerScrewDim = NoRPHoleList.FindAll(item => item.Item.Equals("针板螺丝")).Select(item => item.ItemDim).Distinct().ToList().FirstOrDefault();
            ParamsConfigData.RecommendDimDic.Add("针板螺丝", FallerScrewDim);
            int GPScrewDim = NoRPHoleList.FindAll(item => item.Item.Equals("导柱")).Select(item => item.ItemDim).Distinct().ToList().FirstOrDefault();
            ParamsConfigData.RecommendDimDic.Add("导柱", GPScrewDim);
            //套显示的是零件Dim(套内径)
            ParamsConfigData.RecommendDimDic.Add("A套(导柱)", GPScrewDim);
            ParamsConfigData.RecommendDimDic.Add("B套(导柱)", GPScrewDim);
            int SPScrewDim = NoRPHoleList.FindAll(item => item.Item.Equals("拉杆")).Select(item => item.ItemDim).Distinct().ToList().FirstOrDefault();
            ParamsConfigData.RecommendDimDic.Add("拉杆", SPScrewDim);
            ParamsConfigData.RecommendDimDic.Add("A套(拉杆)", SPScrewDim);
            ParamsConfigData.RecommendDimDic.Add("B套(拉杆)", SPScrewDim);

            if (SmallScrewDim != 0)
            {
                StandardShareScopeItemParam.SmallSScrewDimList.Add(SmallScrewDim);
                int LTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim < SmallScrewDim && item.Item.Equals("小螺丝"))
                    .OrderByDescending(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                int GTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim > SmallScrewDim && item.Item.Equals("小螺丝"))
                    .OrderBy(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                if (LTScrewDim != 0)
                    StandardShareScopeItemParam.SmallSScrewDimList.Add(LTScrewDim);
                if (GTScrewDim != 0)
                    StandardShareScopeItemParam.SmallSScrewDimList.Add(GTScrewDim);
                StandardShareScopeItemParam.SmallSScrewDimList = StandardShareScopeItemParam.SmallSScrewDimList.Distinct().ToList();
            }

            if (BigScrewDim != 0)
            {
                StandardShareScopeItemParam.BigSScrewDimList.Add(BigScrewDim);
                int LTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim < BigScrewDim && item.Item.Equals("大螺丝"))
                    .OrderByDescending(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                int GTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim > BigScrewDim && item.Item.Equals("大螺丝"))
                    .OrderBy(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                if (LTScrewDim != 0)
                    StandardShareScopeItemParam.BigSScrewDimList.Add(LTScrewDim);
                if (GTScrewDim != 0)
                    StandardShareScopeItemParam.BigSScrewDimList.Add(GTScrewDim);
                StandardShareScopeItemParam.BigSScrewDimList = StandardShareScopeItemParam.BigSScrewDimList.Distinct().ToList();
            }

            if (FallerScrewDim != 0)
            {
                StandardShareScopeItemParam.FallerSScrewDimList.Add(FallerScrewDim);
                int LTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim < FallerScrewDim && item.Item.Equals("针板螺丝"))
                    .OrderByDescending(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                int GTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim > FallerScrewDim && item.Item.Equals("针板螺丝"))
                    .OrderBy(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                if (LTScrewDim != 0)
                    StandardShareScopeItemParam.FallerSScrewDimList.Add(LTScrewDim);
                if (GTScrewDim != 0)
                    StandardShareScopeItemParam.FallerSScrewDimList.Add(GTScrewDim);
                StandardShareScopeItemParam.FallerSScrewDimList = StandardShareScopeItemParam.FallerSScrewDimList.Distinct().ToList();
            }

            if (GPScrewDim != 0)
            {
                StandardShareScopeItemParam.GPSScrewDimList.Add(GPScrewDim);
                int LTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim < GPScrewDim && item.Item.Equals("导柱"))
                    .OrderByDescending(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                int GTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim > GPScrewDim && item.Item.Equals("导柱"))
                    .OrderBy(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                if (LTScrewDim != 0)
                    StandardShareScopeItemParam.GPSScrewDimList.Add(LTScrewDim);
                if (GTScrewDim != 0)
                    StandardShareScopeItemParam.GPSScrewDimList.Add(GTScrewDim);
                StandardShareScopeItemParam.GPSScrewDimList = StandardShareScopeItemParam.GPSScrewDimList.Distinct().ToList();
            }

            if (SPScrewDim != 0)
            {
                StandardShareScopeItemParam.SPScrewDimList.Add(SPScrewDim);
                int LTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim < SPScrewDim && item.Item.Equals("拉杆"))
                    .OrderByDescending(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                int GTScrewDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim > SPScrewDim && item.Item.Equals("拉杆"))
                    .OrderBy(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
                if (LTScrewDim != 0)
                    StandardShareScopeItemParam.SPScrewDimList.Add(LTScrewDim);
                if (GTScrewDim != 0)
                    StandardShareScopeItemParam.SPScrewDimList.Add(GTScrewDim);
                StandardShareScopeItemParam.SPScrewDimList = StandardShareScopeItemParam.SPScrewDimList.Distinct().ToList();
            }

        }

        //回针 浮动 下级
        public static void SetRPPerNextHoleScope(int MouldIndex, List<int> MouldSizeList)
        {
            int NowMoldSize = MouldSizeList[MouldIndex];
            int RPDim = ParamsConfigData.MoldHoleList.FindAll(item => item.MouldSize == NowMoldSize
            && item.Item.Equals("回针")).Select(item => item.ItemDim).Distinct().FirstOrDefault();
            ParamsConfigData.RecommendDimDic.Add("回针", RPDim);
            StandardShareScopeItemParam.ReturnPinDimList.Add(RPDim);
            //往上找一级 回针只会做小不会做大
            int LTRPDim = ParamsConfigData.MoldHoleList.FindAll(item => item.ItemDim < RPDim && item.Item.Equals("回针"))
                .OrderByDescending(item => item.ItemDim).Select(item => item.ItemDim).Distinct().FirstOrDefault();
            if (LTRPDim != -1)
                StandardShareScopeItemParam.ReturnPinDimList.Add(LTRPDim);
            StandardShareScopeItemParam.ReturnPinDimList = StandardShareScopeItemParam.ReturnPinDimList.Distinct().ToList();
        }

        //设置零件 标准规格 基本参数范围
        public void SetHoleParamScope(double moldWidth, double moldLength)
        {
            List<int> MouldSizeList = ParamsConfigData.MoldHoleList.Select(item => item.MouldSize).Distinct().OrderBy(item => item).ToList();
            if (MouldSizeList.Count > 0)
            {
                Dictionary<int, List<int>> fitMouldDic = new Dictionary<int, List<int>>();
                for (int i = 0; i < MouldSizeList.Count; i++)
                {
                    string MouldStr = MouldSizeList[i].ToString();
                    string widthStr = MouldStr.Substring(0, 2);
                    string lengthStr = MouldStr.Substring(2, MouldStr.Length - 2);
                    int widthSize = int.Parse(widthStr);
                    int lengthSize = int.Parse(lengthStr);
                    if (!fitMouldDic.ContainsKey(widthSize))
                    {
                        List<int> tLList = new List<int>();
                        tLList.Add(lengthSize);
                        fitMouldDic.Add(widthSize, tLList);
                    }
                    else
                        fitMouldDic[widthSize].Add(lengthSize);
                }
                if (fitMouldDic.Count > 0)
                {
                    string nowWStr = moldWidth.ToString().Substring(0, 2);
                    Boolean WF = int.TryParse(nowWStr, out int resultW);
                    if (WF)
                    {
                        //合适的宽 长
                        int? fitW = null;
                        int? fitL = null;
                        int nowWidth = int.Parse(nowWStr);
                        List<int> widthKeyList = fitMouldDic.Keys.ToList();
                        int accordWIndex = widthKeyList.FindIndex(item => item == nowWidth);
                        if (accordWIndex != -1)
                            fitW = widthKeyList[accordWIndex];
                        else
                        {
                            //上下进行比较 取靠近的
                            int PerWIndex = widthKeyList.FindLastIndex(item => item < nowWidth);
                            int NextWIndex = widthKeyList.FindIndex(item => item > nowWidth);
                            if (PerWIndex != -1 && NextWIndex != -1)
                            {
                                int PerW = widthKeyList[PerWIndex];
                                int NextW = widthKeyList[NextWIndex];
                                //差值
                                int DiffPerW = Math.Abs(PerW - nowWidth);
                                int DiffNextW = Math.Abs(NextW - nowWidth);
                                if (DiffPerW == DiffNextW)
                                    fitW = NextW;
                                else
                                    fitW = DiffPerW < DiffNextW ? PerW : NextW;
                            }
                        }
                        if (fitW != null)
                        {
                            string nowLStr = null;
                            if (fitW <= 60)
                                nowLStr = moldLength.ToString().Substring(0, 2);
                            else
                                nowLStr = moldLength.ToString().Substring(0, 3);
                            Boolean LF = int.TryParse(nowLStr, out int resultL);
                            if (LF)
                            {
                                int nowLength = int.Parse(nowLStr);
                                List<int> lengthScopeList = fitMouldDic[(int)fitW];
                                if (lengthScopeList.Count > 0)
                                {
                                    int accordLIndex = lengthScopeList.FindIndex(item => item == nowLength);
                                    if (accordLIndex != -1)
                                        fitL = lengthScopeList[accordLIndex];
                                    else
                                    {
                                        int PerLIndex = lengthScopeList.FindLastIndex(item => item < nowLength);
                                        int NextLIndex = lengthScopeList.FindIndex(item => item > nowLength);
                                        if (PerLIndex != -1 && NextLIndex != -1)
                                        {
                                            if (PerLIndex == NextLIndex)
                                                fitL = lengthScopeList[PerLIndex];
                                            int DiffPerL = Math.Abs(lengthScopeList[PerLIndex] - nowLength);
                                            int DiffNextL = Math.Abs(lengthScopeList[NextLIndex] - nowLength);
                                            if (DiffPerL == DiffNextL)
                                                fitL = lengthScopeList[NextLIndex];
                                            else
                                                fitL = DiffPerL < DiffNextL ? lengthScopeList[PerLIndex] : lengthScopeList[NextLIndex];
                                        }
                                        else
                                        {
                                            if (PerLIndex != -1)
                                                fitL = lengthScopeList[PerLIndex];
                                            if (NextLIndex != -1)
                                                fitL = lengthScopeList[NextLIndex];
                                        }
                                    }
                                }
                            }
                            if (fitL != null)
                            {
                                int NowMoldSize = int.Parse(fitW.ToString() + fitL.ToString());
                                int MouldIndex = MouldSizeList.FindIndex(item => item == NowMoldSize);
                                if (MouldIndex != -1)
                                {
                                    SetNotRPPerNextHoleScope(MouldIndex, MouldSizeList);
                                    SetRPPerNextHoleScope(MouldIndex, MouldSizeList);
                                }
                            }
                        }
                    }
                }
            }
        }

        //设置拉令 标准规格 基本参数范围
        public void SetPullingParamScope()
        {
            StandardShareScopeItemParam.PullingDimParam = new PullingDimItem();
            //模架规格 宽 长
            int MouldWidth = (int)MoldBaseShare.Width;
            int MouldLength = (int)MoldBaseShare.Length;
            int PullingIndex = -1;
            List<StandardPulling> PList = ParamsConfigData.StandardPullingList;
            if (PList.Count > 0)
            {
                List<int> ABDimList = PList.Select(item => item.AB).Distinct().OrderBy(item => item).ToList();
                List<int> skmbDimList = PList.Select(item => item.skmb).Distinct().OrderBy(item => item).ToList();
                List<int> tuobanDimList = PList.Select(item => item.tuoban).Distinct().OrderBy(item => item).ToList();
                List<int> dbmbDimList = PList.Select(item => item.dbmb).Distinct().OrderBy(item => item).ToList();
                List<int> tuibanDimList = PList.Select(item => item.tuiban).Distinct().OrderBy(item => item).ToList();
                List<int> fangtieDimList = PList.Select(item => item.fangtie).Distinct().OrderBy(item => item).ToList();
                List<int> zhenbanDimList = PList.Select(item => item.zhenban).Distinct().OrderBy(item => item).ToList();
                PullingIndex = PList.FindIndex(item => JudgePullingSizeModelNumber(MouldWidth, MouldLength, item));
                //上下浮动一级
                if (PullingIndex != -1)
                {
                    StandardPulling tempPItem = PList[PullingIndex];
                    int AB = tempPItem.AB;
                    int skmb = tempPItem.skmb;
                    int tuoban = tempPItem.tuoban;
                    int dbmb = tempPItem.dbmb;
                    int tuiban = tempPItem.tuiban;
                    int fangtie = tempPItem.fangtie;
                    int zhenban = tempPItem.zhenban;
                    int ABIndex = ABDimList.FindIndex(item => item == AB);
                    int skmbIndex = skmbDimList.FindIndex(item => item == skmb);
                    int tuobanIndex = tuobanDimList.FindIndex(item => item == tuoban);
                    int dbmbIndex = dbmbDimList.FindIndex(item => item == dbmb);
                    int tuibanIndex = tuibanDimList.FindIndex(item => item == tuiban);
                    int fangtieIndex = fangtieDimList.FindIndex(item => item == fangtie);
                    int zhenbanIndex = zhenbanDimList.FindIndex(item => item == zhenban);

                    if (ABIndex > 0)
                        StandardShareScopeItemParam.PullingDimParam.ABDimList.Add(ABDimList[ABIndex - 1]);
                    StandardShareScopeItemParam.PullingDimParam.ABDimList.Add(ABDimList[ABIndex]);
                    if (ABIndex != ABDimList.Count - 1)
                        StandardShareScopeItemParam.PullingDimParam.ABDimList.Add(ABDimList[ABIndex + 1]);

                    if (skmbIndex > 0)
                        StandardShareScopeItemParam.PullingDimParam.skmbDimList.Add(skmbDimList[skmbIndex - 1]);
                    StandardShareScopeItemParam.PullingDimParam.skmbDimList.Add(skmbDimList[skmbIndex]);
                    if (skmbIndex != skmbDimList.Count - 1)
                        StandardShareScopeItemParam.PullingDimParam.skmbDimList.Add(skmbDimList[skmbIndex + 1]);

                    if (tuobanIndex > 0)
                        StandardShareScopeItemParam.PullingDimParam.tuobanDimList.Add(tuobanDimList[tuobanIndex - 1]);
                    StandardShareScopeItemParam.PullingDimParam.tuobanDimList.Add(tuobanDimList[tuobanIndex]);
                    if (tuobanIndex != tuobanDimList.Count - 1)
                        StandardShareScopeItemParam.PullingDimParam.tuobanDimList.Add(tuobanDimList[tuobanIndex + 1]);

                    if (dbmbIndex > 0)
                        StandardShareScopeItemParam.PullingDimParam.dbmbDimList.Add(dbmbDimList[dbmbIndex - 1]);
                    StandardShareScopeItemParam.PullingDimParam.dbmbDimList.Add(dbmbDimList[dbmbIndex]);
                    if (dbmbIndex != dbmbDimList.Count - 1)
                        StandardShareScopeItemParam.PullingDimParam.dbmbDimList.Add(dbmbDimList[dbmbIndex + 1]);

                    if (tuibanIndex > 0)
                        StandardShareScopeItemParam.PullingDimParam.tuibanDimList.Add(tuibanDimList[tuibanIndex - 1]);
                    StandardShareScopeItemParam.PullingDimParam.tuibanDimList.Add(tuibanDimList[tuibanIndex]);
                    if (tuibanIndex != tuibanDimList.Count - 1)
                        StandardShareScopeItemParam.PullingDimParam.tuibanDimList.Add(tuibanDimList[tuibanIndex + 1]);

                    if (fangtieIndex > 0)
                        StandardShareScopeItemParam.PullingDimParam.fangtieDimList.Add(fangtieDimList[fangtieIndex - 1]);
                    StandardShareScopeItemParam.PullingDimParam.fangtieDimList.Add(fangtieDimList[fangtieIndex]);
                    if (fangtieIndex != fangtieDimList.Count - 1)
                        StandardShareScopeItemParam.PullingDimParam.fangtieDimList.Add(fangtieDimList[fangtieIndex + 1]);

                    if (zhenbanIndex > 0)
                        StandardShareScopeItemParam.PullingDimParam.zhenbanDimList.Add(zhenbanDimList[zhenbanIndex - 1]);
                    StandardShareScopeItemParam.PullingDimParam.zhenbanDimList.Add(zhenbanDimList[zhenbanIndex]);
                    if (zhenbanIndex != zhenbanDimList.Count - 1)
                        StandardShareScopeItemParam.PullingDimParam.zhenbanDimList.Add(zhenbanDimList[zhenbanIndex + 1]);
                }
            }
        }

        //判断近似同心
        private ApprConCircleKey JudgeCirclePointApprCon(Dictionary<CircleKey, List<MixedCAD_Circle>> Dic, CircleKey keyPoint)
        {
            ApprConCircleKey Res = new ApprConCircleKey();
            List<CircleKey> refKList = Dic.Keys.ToList();
            int sameIndex = refKList.FindIndex(item => item.Equals(keyPoint));
             if (sameIndex != -1)
             {
                 CircleKey apprKey = refKList[sameIndex];
                 Res.refKey = refKList[sameIndex];
                 Res.comF = true;
             }
            return Res;
        }

        //近似处理 EGP 平面图 同心圆
        public Dictionary<CircleKey, List<MixedCAD_Circle>> ProcessEGPConCircles(List<MixedCAD_Circle> CadCircleList)
        {
            //同心圆归类 
            Dictionary<CircleKey, List<MixedCAD_Circle>> ConCirclesDic = new Dictionary<CircleKey, List<MixedCAD_Circle>>();
            if (CadCircleList.Count > 0)
            {
                CadCircleList.ForEach(item =>
                {
                    CircleKey tempKey = new CircleKey { CircleX = item.CenterPoint.CustomerPoint.X, CircleY = item.CenterPoint.CustomerPoint.Y };
                    ApprConCircleKey apprInfo = JudgeCirclePointApprCon(ConCirclesDic, tempKey);
                    if (apprInfo.comF)
                        ConCirclesDic[apprInfo.refKey].Add(item);
                    else
                        ConCirclesDic.Add(tempKey, new List<MixedCAD_Circle> { item });
                });
            }

            List<CircleKey> keyList = ConCirclesDic.Keys.ToList();
            if (keyList.Count > 0)
            {
                for (int i = 0; i < keyList.Count; i++)
                {
                    List<MixedCAD_Circle> tempItem = ConCirclesDic[keyList[i]];
                    if (tempItem.Count > 0)
                    {
                        List<double> tempdimList = tempItem.Select(item => item.Diameter).ToList();
                        double targetDim = tempdimList.Min();
                        int targetIndex = tempItem.FindIndex(item => item.Diameter == targetDim);
                        MixedCAD_Circle targetEntity = tempItem[targetIndex];
                        ConCirclesDic[keyList[i]] = new List<MixedCAD_Circle>() { targetEntity };
                    }
                }
            }
            return ConCirclesDic;
        }
        //处理 平面图 同心圆(Key 绝对坐标)
        public Dictionary<CircleKey, List<MixedCAD_Circle>> ProcessConCircles(List<MixedCAD_Circle> CadCircleList)
        {
            //同心圆归类 
            Dictionary<CircleKey, List<MixedCAD_Circle>> ConCirclesDic = new Dictionary<CircleKey, List<MixedCAD_Circle>>();
            if (CadCircleList.Count > 0)
            {
                CadCircleList.ForEach(item =>
                {
                    CircleKey tempKey = new CircleKey { CircleX = item.CenterPoint.CustomerPoint.X, CircleY = item.CenterPoint.CustomerPoint.Y };
                    ApprConCircleKey apprInfo = JudgeCirclePointApprCon(ConCirclesDic, tempKey);
                    if (apprInfo.comF)
                        ConCirclesDic[apprInfo.refKey].Add(item);
                    else
                        ConCirclesDic.Add(tempKey, new List<MixedCAD_Circle> { item });
                });
            }

            List<CircleKey> keyList = ConCirclesDic.Keys.ToList();
            if (keyList.Count > 0)
            {
                for (int i = 0; i < keyList.Count; i++)
                {
                    List<MixedCAD_Circle> tempItem = ConCirclesDic[keyList[i]];
                    if (tempItem.Count > 0)
                    {
                        List<MixedCAD_Circle> resItem = new List<MixedCAD_Circle>();
                        for (int j = 0; j < tempItem.Count; j++)
                        {
                            Boolean F = resItem.FindIndex(item => item.Equals(tempItem[j])) == -1;
                            if (F)
                                resItem.Add(tempItem[j]);
                        }
                        ConCirclesDic[keyList[i]] = resItem;
                    }
                }
            }
            return ConCirclesDic;
        }

        public Boolean MixedCircleCoorNearEQ(MixedCAD_Circle cir1, MixedCAD_Circle cir2)
        {
            Boolean F1 = Math.Round(cir1.CenterPoint.CustomerPoint.X, 0) == Math.Round(cir2.CenterPoint.CustomerPoint.X, 0);
            Boolean F2 = Math.Round(cir1.CenterPoint.CustomerPoint.Y, 0) == Math.Round(cir2.CenterPoint.CustomerPoint.Y, 0);
            return F1 && F2;
        }

        public List<ConSpeCircle> SameCirDicTransToConSpe(Dictionary<CircleKey, List<MixedCAD_Circle>> CirDic)
        {
            List<ConSpeCircle> Res = new List<ConSpeCircle>();
            List<CircleKey> keyList = CirDic.Keys.ToList();
            for(int i = 0; i< keyList.Count; i++)
            {
                ConSpeCircle tempItem = new ConSpeCircle();
                tempItem.CustomerConHPoint.X = keyList[i].CircleX;
                tempItem.CustomerConHPoint.Y = keyList[i].CircleY;
                tempItem.ConRefPoint = GetHoleRefPoint(keyList[i]);
                List<MixedCAD_Circle> ttList = CirDic[keyList[i]];
                for(int j = 0; j < ttList.Count; j++)
                    tempItem.DimList.Add(ttList[j].Diameter);
                if(tempItem.DimList.Count > 0)
                    tempItem.DimList = tempItem.DimList.OrderBy(item => item).ToList();
                Res.Add(tempItem);
            }
            return Res;
        }



        //同心圆类 -> 转换 -> 合并 KEY 圆圈数量 + 各圆Dim大小 组合特征 VALUE ConSpeCircle List集合 
        public Dictionary<string, List<ConSpeCircle>> TranMergeConSpeCircle(Dictionary<CircleKey, List<MixedCAD_Circle>> targetDic)
        {
            List<ConSpeCircle> tempList = new List<ConSpeCircle>();
            List<CircleKey> ckeyList = targetDic.Keys.ToList();
            for (int i = 0; i < ckeyList.Count; i++)
            {
                ConSpeCircle Item = new ConSpeCircle();
                List<MixedCAD_Circle> tempItem = targetDic[ckeyList[i]];
                int Cnum = tempItem.Count;
                string DimStr = null;
                List<double> dimList = tempItem.Select(item => item.Diameter).ToList();
                dimList = dimList.OrderBy(item => item).ToList();
                dimList.ForEach(item =>
                {
                    Item.DimList.Add(item);
                    DimStr += item.ToString();
                });
                Item.SpeTrait = DimStr;
                Item.CustomerConHPoint.X = ckeyList[i].CircleX;
                Item.CustomerConHPoint.Y = ckeyList[i].CircleY;
                Item.ConRefPoint = GetHoleRefPoint(ckeyList[i]);
                tempList.Add(Item);
            }
            Dictionary<string, List<ConSpeCircle>> Res = new Dictionary<string, List<ConSpeCircle>>();
            for (int i = 0; i < tempList.Count; i++)
            {
                string tempTraitKey = tempList[i].SpeTrait;
                if (Res.ContainsKey(tempTraitKey))
                    Res[tempTraitKey].Add(tempList[i]);
                else
                    Res.Add(tempTraitKey, new List<ConSpeCircle>() { tempList[i] });
            }
            return Res;
        }

        //删除掉EGP的干扰
        public Dictionary<string, List<ConSpeCircle>> FilterEGPSpe(Dictionary<string, List<ConSpeCircle>> targetDic, Dictionary<string, List<ConSpeCircle>> EGPDic)
        {
            Dictionary<string, List<ConSpeCircle>> ResDic = new Dictionary<string, List<ConSpeCircle>>();
            List<string> allKeys = targetDic.Keys.ToList();
            List<string> egpKeys = EGPDic.Keys.ToList();
            allKeys.RemoveAll(item => egpKeys.Contains(item));
            if (allKeys.Count > 0)
            {
                for (int i = 0; i < allKeys.Count; i++)
                    ResDic.Add(allKeys[i], targetDic[allKeys[i]]);
            }
            return ResDic;
        }

        //EGP同坐标问题
        public void FilterSameCoorEGP(Dictionary<string, List<ConSpeCircle>> EGPDic)
        {
            if (EGPDic.Keys.Count > 0)
            {
                List<string> resKeys = EGPDic.Keys.ToList();
                for (int i = 0; i < resKeys.Count; i++)
                {
                    List<ConSpeCircle> tempList = EGPDic[resKeys[i]];
                    if(tempList.Count > 1)
                    {
                        int dimCount = tempList.Select(item => item.DimList.Count).Max();
                        int targetIndex = tempList.FindIndex(item => item.DimList.Count == dimCount);
                        if (targetIndex != -1)
                            EGPDic[resKeys[i]] = new List<ConSpeCircle>() { tempList[targetIndex] };
                    }
                }
            }
        }

        //处理组装图 拉令图元数据
        public List<AralinPrimions> PALConCircles(List<MixedCAD_Circle> CadCircleList, List<MixedCAD_Arc> CadArcList, List<MixedCAD_Text> TextList)
        {
            List<AralinPrimions> PAList = new List<AralinPrimions>();
            if (CadCircleList.Count > 0)
            {
                for (int i = 0; i < CadCircleList.Count; i++)
                {
                    AralinPrimions Item = new AralinPrimions();
                    if (CadCircleList[i].IsBlockEleFlag)
                    {
                        Item.CenterX = Math.Round(CadCircleList[i].BlockRefPosition.CustomerPoint.X + CadCircleList[i].CenterPoint.CustomerPoint.X, 3);
                        Item.CenterY = Math.Round(CadCircleList[i].BlockRefPosition.CustomerPoint.Y + CadCircleList[i].CenterPoint.CustomerPoint.Y, 3);
                        Item.CircleList.Add(CadCircleList[i]);
                    }
                    else
                    {
                        Item.CenterX = Math.Round(CadCircleList[i].CenterPoint.CustomerPoint.X, 3);
                        Item.CenterY = Math.Round(CadCircleList[i].CenterPoint.CustomerPoint.Y, 3);
                        Item.CircleList.Add(CadCircleList[i]);
                    }
                    int EIndex = PAList.FindIndex(item => item.CenterX == Item.CenterX && item.CenterY == Item.CenterY);
                    if (EIndex == -1)
                        PAList.Add(Item);
                    else
                        PAList[EIndex].CircleList.Add(CadCircleList[i]);
                }

                //关联块 圆弧
                if (PAList.Count > 0 && CadArcList.Count > 0)
                {
                    //List<CAD_Arc> BlockCadArcList = CadArcList.FindAll(item => item.IsBlockEleFlag).ToList();
                    //if(BlockCadArcList.Count > 0)
                    //{
                    //    for (int i = 0; i < CadArcList.Count; i++)
                    //    {
                    //        double ArcX = Math.Round(CadArcList[i].CenterPoint.X, 3);
                    //        double ArcY = Math.Round(CadArcList[i].CenterPoint.Y, 3);
                    //        if (CadArcList[i].IsBlockEleFlag)
                    //        {
                    //            int EIndex = PAList.FindIndex(item => item.CenterX == ArcX && item.CenterY == ArcY);
                    //            if (EIndex != -1)
                    //            {
                    //                PAList[EIndex].IsContainArcFlag = true;
                    //                PAList[EIndex].OutSideArc = CadArcList[i];
                    //            }
                    //        }
                    //    }
                    //}
                    for (int i = 0; i < CadArcList.Count; i++)
                    {
                        double ArcX = Math.Round(CadArcList[i].CenterPoint.CustomerPoint.X, 3);
                        double ArcY = Math.Round(CadArcList[i].CenterPoint.CustomerPoint.Y, 3);
                        int EIndex = PAList.FindIndex(item => item.CenterX == ArcX && item.CenterY == ArcY);
                        if (EIndex != -1)
                        {
                            PAList[EIndex].IsContainArcFlag = true;
                            PAList[EIndex].OutSideArc = CadArcList[i];
                        }
                    }
                }

                ////关联块 文字标注(半径)
                //if (PAList.Count > 0 && TextList.Count > 0)
                //{
                //    List<CAD_Text> BlockCadTextList = TextList.FindAll(item => item.IsBlockEleFlag).ToList();
                //    if (BlockCadTextList.Count > 0)
                //    {
                //        for (int i = 0; i < BlockCadTextList.Count; i++)
                //        {
                //            /*double textX = Math.Round(BlockCadTextList[i].PositionPoint.X, 3);
                //            double textY = Math.Round(BlockCadTextList[i].PositionPoint.Y, 3);
                //            //在圆内都算
                //            if (BlockCadTextList[i].IsBlockEleFlag)
                //            {

                //                int EIndex = PAList.FindIndex(item => item.CenterX - item.
                //                && item.CenterY == textY);
                //                if (EIndex != -1)
                //                {
                //                    PAList[EIndex].IsContainArcFlag = true;
                //                    PAList[EIndex].RadiusLabel = CadArcList[i];
                //                }
                //            }*/
                //        }
                //    }
                //}

            }

            return PAList;
        }


        //根据型号 推断标准拉令下标
        public static Boolean JudgePullingSizeModelNumber(int MouldWidth, int MouldLength, StandardPulling PItem)
        {
            Boolean F1 = PItem.minW <= MouldWidth && MouldWidth <= PItem.maxW;
            Boolean F2 = PItem.minL <= MouldLength && MouldLength <= PItem.maxL;
            return F1 && F2;
        }

        //根据型号 自动推断拉令Dim 主要涉及到提仓业务 
        //当小于45的标模型号出现 一律按照标准去补拉令Dim
        public static void SetPullingDim(string BoardCode, HangingOrderItemParam ItemParam, double CustomDim)
        {
            //模架规格大小
            int NowMoldSize = int.Parse(MoldBaseShare.Width.ToString().Substring(0, 2) + MoldBaseShare.Length.ToString().Substring(0, 2));
            //<= 45 的标模型号
            List<int> MicroMoldSizeList = new List<int>() { 1515, 2030, 2031, 2340, 2525, 2940, 3030, 3035, 3040, 3060, 3335, 3360, 3535, 3570, 4040, 4044, 4045 };
            Boolean F = MicroMoldSizeList.FindIndex(item => item == NowMoldSize) != -1;
            //自动补齐
            if (F)
            {
                int WSize = int.Parse(MoldBaseShare.Width.ToString().Substring(0, 2) + "0");
                int LSize = int.Parse(MoldBaseShare.Length.ToString().Substring(0, 2) + "0");
                StandardPulling SItem = ParamsConfigData.StandardPullingList.Find(item => (item.minW == WSize || item.maxW == WSize)
                && (item.minL == LSize || item.maxL == LSize));

                if (SItem != null)
                {
                    if (BoardCode.Equals("aBoard") || BoardCode.Equals("bBoard"))
                        ItemParam.Dim = SItem.AB;
                    if (BoardCode.Equals("cpBoard"))
                        ItemParam.Dim = SItem.skmb;
                    if (BoardCode.Equals("spBoard"))
                        ItemParam.Dim = SItem.tuoban;
                    if (BoardCode.Equals("bpBoard"))
                        ItemParam.Dim = SItem.dbmb;
                    //水口推板 推板、流道板 -> tuiban
                    if (BoardCode.Equals("stBoard") || BoardCode.Equals("rspBoard") || BoardCode.Equals("rBoard"))
                        ItemParam.Dim = SItem.tuiban;
                    if (BoardCode.Equals("fangtie"))
                        ItemParam.Dim = SItem.fangtie;
                    if (BoardCode.Equals("fpBoard") || BoardCode.Equals("epBoard"))
                        ItemParam.Dim = SItem.zhenban;
                }
            }
            // 不自动补齐 按客图
            else
                ItemParam.Dim = CustomDim;
            MicroMoldSizeList.Clear();
        }

        //孔 推算相对坐标
        public CAD_Point GetHoleRefPoint(CircleKey targetPoint)
        {
            CAD_Point Res = new CAD_Point();
            MixedCAD_Point modlPInfo = RecognizeUtils.WholeTopViewData.ModlCenterInfo;
            CAD_Point absPoint = modlPInfo.CustomerPoint;
            Res.X = targetPoint.CircleX - absPoint.X;
            Res.Y = targetPoint.CircleY - absPoint.Y;
            return Res;
        }

        //获取孔分中距离
        public double GetHoelCD(CAD_Point point)
        {
            double X = point.X;
            double Y = point.Y;
            Boolean F1 = X != 0;
            Boolean F2 = Y != 0;
            if (F1 && F2)
                return Math.Sqrt(X * X + Y * Y);
            else
            {
                if (F1)
                    return Math.Abs(X);
                if (F2)
                    return Math.Abs(Y);
            }
            return 0;
        }

        public void SetCirDicPosType(List<ConSpeCircle> argList)
        {
            var flxValue = FangtieShareData.FLXInfo;
            var frxValue = FangtieShareData.FRXInfo;
            if (flxValue != null && frxValue != null)
            {
                double FLXInfo = (double)flxValue.SplitX;
                double FRXInfo = (double)frxValue.SplitX;
                for(int i = 0; i < argList.Count; i++)
                {
                    double cirX = argList[i].CustomerConHPoint.X;
                    Boolean LF = cirX < FLXInfo;
                    Boolean RF = cirX > FRXInfo;
                    Boolean CF = FLXInfo < cirX &&  cirX < FRXInfo;
                    if (LF)
                        argList[i].fPosType = FPosType.L;
                    if (RF)
                        argList[i].fPosType = FPosType.R;
                    if (CF)
                        argList[i].fPosType = FPosType.C;
                }
            }
        }

        public void Step1_BlurHCAppoint(List<ConSpeCircle> targetList)
        {
            List<HoleCir> ResList = new List<HoleCir>();
            List<int> rpDimList = StandardShareScopeItemParam.ReturnPinDimList;
            List<int> gpDimlist = StandardShareScopeItemParam.GPSScrewDimList;
            Boolean exitEPFP = false;
            double epfpMinX = 0;
            double epfpMaxX = 0;
            List<BoardSectionItem> epfpBoardList = AssemblyShareData.ASectionList.FindAll(item => item.BoardCode.Equals("epBoard")
                || item.BoardCode.Equals("fpBoard"));
            if (epfpBoardList.Count > 0)
                exitEPFP = true;
            if (exitEPFP)
            {
                 epfpMinX = epfpBoardList.Select(item => item.OverheadLine.StartPoint.CustomerPoint.X).Min();
                 epfpMaxX = epfpBoardList.Select(item => item.OverheadLine.EndPoint.CustomerPoint.X).Max();
            }
            if (targetList.Count > 0)
            {
                for(int i = 0; i < targetList.Count; i++)
                {
                    List<double> tempDimList = targetList[i].DimList;
                    int dimNum = tempDimList.Count;
                    if (dimNum == 1)
                    {
                        double firstDim = tempDimList.First();
                        if (JudgeSPBK(firstDim))
                        {
                            HoleCir tempItem = new HoleCir();
                            tempItem.fPosType = targetList[i].fPosType;
                            tempItem.holeType = HoleType.SP;
                            tempItem.CCPoint.X = targetList[i].CustomerConHPoint.X;
                            tempItem.CCPoint.Y = targetList[i].CustomerConHPoint.Y;
                            HolePartDInfo partInfo = new HolePartDInfo();
                            partInfo.partType = PartType.BK;
                            partInfo.Dim = firstDim;
                            partInfo.sortIndex = 0;
                            tempItem.cirNum = 1;
                            tempItem.HolePartInfoList.Add(partInfo);
                            ResList.Add(tempItem);
                        }
                        if (exitEPFP)
                        {
                            double tempPosX = targetList[i].CustomerConHPoint.X;
                            Boolean betweenEPFPF = epfpMinX <= tempPosX && tempPosX <= epfpMaxX;
                            if (betweenEPFPF)
                            {
                                if (JudgeRPDim(firstDim, rpDimList))
                                {
                                    HoleCir tempItem = new HoleCir();
                                    tempItem.fPosType = targetList[i].fPosType;
                                    tempItem.holeType = HoleType.RP;
                                    tempItem.CCPoint.X = targetList[i].CustomerConHPoint.X;
                                    tempItem.CCPoint.Y = targetList[i].CustomerConHPoint.Y;
                                    HolePartDInfo partInfo = new HolePartDInfo();
                                    partInfo.partType = PartType.Dim;
                                    partInfo.Dim = firstDim;
                                    partInfo.sortIndex = 0;
                                    tempItem.HolePartInfoList.Add(partInfo);
                                    ResList.Add(tempItem);
                                }
                            }
                        }
                    }
                    else
                    {
                        for(int j = 0; j < dimNum - 1; j++)
                        {
                            int k = j + 1;
                            if (JudgeEpScrewOutAndDim(tempDimList[j], tempDimList[k]))
                            {
                                HoleCir tempItem = new HoleCir();
                                tempItem.fPosType = targetList[i].fPosType;
                                tempItem.holeType = HoleType.epfpScrew;
                                tempItem.CCPoint.X = targetList[i].CustomerConHPoint.X;
                                tempItem.CCPoint.Y = targetList[i].CustomerConHPoint.Y;
                                HolePartDInfo partInfo1 = new HolePartDInfo();
                                partInfo1.partType = PartType.Dim;
                                partInfo1.Dim = tempDimList[j];
                                partInfo1.sortIndex = j;
                                HolePartDInfo partInfo2 = new HolePartDInfo();
                                partInfo2.partType = PartType.TD;
                                partInfo2.Dim = tempDimList[k];
                                partInfo2.sortIndex = k;
                                tempItem.HolePartInfoList.Add(partInfo1);
                                tempItem.HolePartInfoList.Add(partInfo2);
                                ResList.Add(tempItem);
                            }
                        }
                    }
                    
                }

            }
        }

        //1阶段 根据规则严格约束 收集归类孔
        public void Step1_CoaGraCollectHole(List<ConSpeCircle> argList)
        {
            List<int> rpDimList = StandardShareScopeItemParam.ReturnPinDimList;
            List<int> gpDimlist = StandardShareScopeItemParam.GPSScrewDimList;
            if (argList.Count > 0)
            {
                ConSpeCircle firstItem = argList[0];
                List<double> tempDimList = firstItem.DimList;
                int dimNum = tempDimList.Count;
                Boolean betweenEPFPF = false;
                Boolean FLXF = false;
                Boolean FRXF = false;
                //ERROR
                if (FangtieShareData.HasLRF)
                {
                    FLXF = firstItem.CustomerConHPoint.X <= FangtieShareData.FLXInfo.SplitX;
                    FRXF = firstItem.CustomerConHPoint.X >= FangtieShareData.FRXInfo.SplitX;
                }
                else
                {
                    FLXF = firstItem.CustomerConHPoint.X <= FangtieShareData.NOFLXInfo.SplitX;
                    FRXF = firstItem.CustomerConHPoint.X >= FangtieShareData.NOFRXInfo.SplitX;
                }
                List<BoardSectionItem> epfpBoardList = AssemblyShareData.ASectionList.FindAll(item => item.BoardCode.Equals("epBoard")
                || item.BoardCode.Equals("fpBoard"));
                if (epfpBoardList.Count > 0)
                {
                    double epfpMinX = epfpBoardList.Select(item => item.OverheadLine.StartPoint.TransSplitPoint.X).Min();
                    double epfpMaxX = epfpBoardList.Select(item => item.OverheadLine.EndPoint.TransSplitPoint.X).Max();
                    betweenEPFPF = epfpMinX <= firstItem.ConRefPoint.X && firstItem.ConRefPoint.X <= epfpMaxX;
                }
                //单圆
                if (dimNum == 1)
                {
                    if (FLXF || FRXF)
                    {
                        if (JudgeSPBK(tempDimList[0]))
                        {
                            MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                            if (holeInfo.HasF)
                            {
                                HoleGroupTag spTag = new HoleGroupTag();
                                spTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                spTag.holeArg.BK = (int)tempDimList[0];
                                spTag.drawDimList.AddRange(tempDimList);
                                spTag.dimList.Add(tempDimList[0]);
                                spTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                CoaGraHoleTagData.CoaSPScrewCList.Add(spTag);
                            }
                        }
                    }
                    if (betweenEPFPF)
                    {
                        if (JudgeRPDim(tempDimList[0], rpDimList))
                        {
                            MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                            if (holeInfo.HasF)
                            {
                                HoleGroupTag fpepTag = new HoleGroupTag();
                                fpepTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                fpepTag.holeArg.Dim = Math.Round(tempDimList[0], 1);
                                fpepTag.drawDimList.AddRange(tempDimList);
                                fpepTag.dimList.Add(tempDimList[0]);
                                fpepTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                CoaGraHoleTagData.CoaReturnPinCList.Add(fpepTag);
                            }
                        }
                    }
                }
                else
                {
                    //至少2圈圆以上(两个零件重合也可能) 圆可能会画欠 需要多些判断  so会重复 后面要根据圆心和直径去重
                    for (int i = 0; i < dimNum - 1; i++)
                    {
                        int j = i + 1;

                        if (JudgeEpScrewOutAndDim(tempDimList[i], tempDimList[j]))
                        {
                            MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                            if (holeInfo.HasF)
                            {
                                HoleGroupTag bpTag = new HoleGroupTag();
                                bpTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                bpTag.holeArg.Dim = Math.Round(tempDimList[i], 1);
                                bpTag.holeArg.TD = (int)tempDimList[j];
                                bpTag.dimList.Add(tempDimList[i]);
                                bpTag.dimList.Add(tempDimList[j]);
                                bpTag.drawDimList.AddRange(tempDimList);
                                bpTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                CoaGraHoleTagData.CoaSmallScrewCList.Add(bpTag);
                            }
                        }

                        if (JudgeEpScrewInAndDim(tempDimList[i], tempDimList[j]))
                        {
                            MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                            if (holeInfo.HasF)
                            {
                                HoleGroupTag spTag = new HoleGroupTag();
                                spTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                spTag.holeArg.Dim = Math.Round(tempDimList[j], 1);
                                spTag.dimList.Add(tempDimList[j]);
                                spTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                CoaGraHoleTagData.CoaSmallScrewCList.Add(spTag);
                            }
                        }

                        if (JudgeBigScrewOutAndDim(tempDimList[i], tempDimList[j]))
                        {
                            MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                            if (holeInfo.HasF)
                            {
                                HoleGroupTag bigTag = new HoleGroupTag();
                                bigTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                bigTag.holeArg.Dim = Math.Round(tempDimList[i], 1);
                                bigTag.dimList.Add(tempDimList[i]);
                                bigTag.drawDimList.AddRange(tempDimList);
                                bigTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                CoaGraHoleTagData.CoaBigScrewCList.Add(bigTag);
                            }
                        }

                        if (JudgeBigScrewInAndDim(tempDimList[i], tempDimList[j]))
                        {
                            MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                            if (holeInfo.HasF)
                            {
                                HoleGroupTag bigTag = new HoleGroupTag();
                                bigTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                bigTag.holeArg.Dim = Math.Round(tempDimList[j], 1);
                                bigTag.drawDimList.AddRange(tempDimList);
                                bigTag.dimList.Add(tempDimList[j]);
                                bigTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                CoaGraHoleTagData.CoaBigScrewCList.Add(bigTag);
                            }
                        }

                        //上下针板范围内
                        if (epfpBoardList.Count > 0)
                        {
                            double MinX = epfpBoardList.Min(item => item.BottomLine.StartPoint.TransSplitPoint.X);
                            double MaxX = epfpBoardList.Max(item => item.BottomLine.EndPoint.TransSplitPoint.X);
                            if (MinX < firstItem.ConRefPoint.X && firstItem.ConRefPoint.X < MaxX)
                            {
                                //针板螺丝
                                if (JudgeFallerScrewOutAndDim(tempDimList[i], tempDimList[j]))
                                {
                                    if (betweenEPFPF)
                                    {
                                        MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                                        HoleGroupTag fpepTag = new HoleGroupTag();
                                        fpepTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                        fpepTag.holeArg.Dim = Math.Round(tempDimList[i], 1);
                                        fpepTag.drawDimList.AddRange(tempDimList);
                                        fpepTag.dimList.Add(tempDimList[i]);
                                        fpepTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                        CoaGraHoleTagData.CoaFallerScrewCList.Add(fpepTag);
                                    }
                                }
                                if (JudgeFallerScrewInAndDim(tempDimList[i], tempDimList[j]))
                                {
                                    MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                                    if (holeInfo.HasF)
                                    {
                                        HoleGroupTag fpepTag = new HoleGroupTag();
                                        fpepTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                        fpepTag.holeArg.Dim = Math.Round(tempDimList[j], 1);
                                        fpepTag.drawDimList.AddRange(tempDimList);
                                        fpepTag.dimList.Add(tempDimList[j]);
                                        fpepTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                        CoaGraHoleTagData.CoaFallerScrewCList.Add(fpepTag);
                                    }
                                }
                                //回针
                                if (JudgeRPDimAndOutDim(tempDimList[i], tempDimList[j], rpDimList))
                                {
                                    if (betweenEPFPF)
                                    {
                                        MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                                        HoleGroupTag fpepTag = new HoleGroupTag();
                                        fpepTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                        fpepTag.holeArg.Dim = Math.Round(tempDimList[i], 1);
                                        fpepTag.drawDimList.AddRange(tempDimList);
                                        fpepTag.dimList.Add(tempDimList[i]);
                                        fpepTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                        CoaGraHoleTagData.CoaReturnPinCList.Add(fpepTag);
                                    }
                                }
                            }
                        }

                        //导柱
                        if (JudgeGPDimTD(tempDimList[i], tempDimList[j], gpDimlist))
                        {
                            //有针板 需要在针板两侧
                            if (!betweenEPFPF)
                            {
                                MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                                if (holeInfo.HasF)
                                {
                                    HoleGroupTag gpTag = new HoleGroupTag();
                                    gpTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                    gpTag.holeArg.Dim = Math.Round(tempDimList[i], 1);
                                    gpTag.holeArg.TD = (int)tempDimList[j];
                                    gpTag.dimList.Add(tempDimList[i]);
                                    gpTag.dimList.Add(tempDimList[j]);
                                    gpTag.drawDimList.AddRange(tempDimList);
                                    gpTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                    CoaGraHoleTagData.CoaGPScrewCList.Add(gpTag);
                                }
                            }
                        }
                        if (JudgeGPDimBushSize(tempDimList[i], tempDimList[j], gpDimlist))
                        {
                            if (!betweenEPFPF)
                            {
                                MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                                if (holeInfo.HasF)
                                {
                                    HoleGroupTag gpTag = new HoleGroupTag();
                                    gpTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                    gpTag.holeArg.Dim = Math.Round(tempDimList[i], 1);
                                    gpTag.holeArg.BushSize = (int)tempDimList[j];
                                    gpTag.dimList.Add(tempDimList[i]);
                                    gpTag.dimList.Add(tempDimList[j]);
                                    gpTag.drawDimList.AddRange(tempDimList);
                                    gpTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                    CoaGraHoleTagData.CoaGPScrewCList.Add(gpTag);
                                }
                            }
                        }
                        //方铁两侧
                        if (FLXF || FRXF)
                        {
                            //拉杆
                            if (JudgeSPDimBushSize(tempDimList[i], tempDimList[j]))
                            {
                                MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                                if (holeInfo.HasF)
                                {
                                    HoleGroupTag spTag = new HoleGroupTag();
                                    spTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                    spTag.drawDimList.AddRange(tempDimList);
                                    spTag.dimList.Add(tempDimList[i]);
                                    spTag.dimList.Add(tempDimList[j]);
                                    spTag.holeArg.Dim = Math.Round(tempDimList[i], 1);
                                    spTag.holeArg.BushSize = (int)tempDimList[j];
                                    spTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                    CoaGraHoleTagData.CoaSPScrewCList.Add(spTag);
                                }
                            }
                            if (JudgeSPDimBushTD(tempDimList[i], tempDimList[j]))
                            {
                                MixHoleGorupInfo holeInfo = TranssToTagHoleDataLogic(argList);
                                if (holeInfo.HasF)
                                {
                                    HoleGroupTag spTag = new HoleGroupTag();
                                    spTag.CD = GetHoelCD(firstItem.ConRefPoint);
                                    spTag.drawDimList.AddRange(tempDimList);
                                    spTag.dimList.Add(tempDimList[i]);
                                    spTag.dimList.Add(tempDimList[j]);
                                    spTag.holeArg.Dim = Math.Round(tempDimList[i], 1);
                                    spTag.holeArg.BushTD = (int)tempDimList[j];
                                    spTag.CollectionHPList.AddRange(holeInfo.CustomerHolePList);
                                    CoaGraHoleTagData.CoaSPScrewCList.Add(spTag);
                                }
                            }
                        }

                    }
                }

            }
        }

        public void EGPHoleArg()
        {
            List<ScrewHole> EGPScrewHoleList = new List<ScrewHole>();
            List<double> DimList = new List<double>();
            //Ref RPDim 以导柱的上下一级作为参考 By EGP
            SingleItem RPScrew = ShareItemData.ItemList.Find(item => item.ItemNameType == DItemNameType.ReturnPin);
            if (RPScrew != null)
            {
                double RefDim = Math.Round(RPScrew.Dim, 1);
                int CDimIndex = ParamsConfigData.StandardEGPList.FindIndex(item => item.Dimension - 1 <= RefDim 
                && RefDim <= item.Dimension + 1);
                if (CDimIndex != -1)
                {
                    DimList.Add(ParamsConfigData.StandardEGPList[CDimIndex].Dimension);
                    if (CDimIndex > 0)
                        DimList.Add(ParamsConfigData.StandardEGPList[CDimIndex - 1].Dimension);
                    if (CDimIndex != ParamsConfigData.StandardEGPList.Count - 1)
                        DimList.Add(ParamsConfigData.StandardEGPList[CDimIndex + 1].Dimension);
                }
            }

            Dictionary<CircleKey, List<MixedCAD_Circle>> egpDic = RecognizeUtils.WholeTopViewData.EGPConnCircleDic;
            if (egpDic.Keys.Count > 0)
            {
                List<CircleKey> EGPKList = egpDic.Keys.ToList();
                for (int i = 0; i < EGPKList.Count; i++)
                {
                    List<MixedCAD_Circle> CList = egpDic[EGPKList[i]];
                    if (CList.Count > 0)
                    {
                        CList = CList.OrderBy(item => item.Diameter).ToList();
                        //最内圈圆Dim
                        MixedCAD_Circle mayBeEGP = CList[0];
                        double mayBeDim = mayBeEGP.Diameter;
                        ScrewHole Item = new ScrewHole();
                        Item.CenterPoint = new MixedCAD_Point();
                        Item.CenterPoint.CustomerPoint.X = mayBeEGP.CenterPoint.CustomerPoint.X;
                        Item.CenterPoint.CustomerPoint.Y = mayBeEGP.CenterPoint.CustomerPoint.Y;
                        Item.Dim = Math.Round(mayBeDim,1);
                        EGPScrewHoleList.Add(Item);
                    }
                }
                if(EGPScrewHoleList.Count >0)
                    HoleCandidateShareData.EGPScrewCList = ReDupAndPerEGPHole(EGPScrewHoleList);
            }

            List<ScrewHole> EGPList = HoleCandidateShareData.EGPScrewCList;
            MixedCAD_Point modlHInfo = RecognizeUtils.WholeTopViewData.ModlCenterInfo;
            CAD_Point refPoint = modlHInfo.CustomerPoint;
            ComputedUtils.CalTViewHoleSplitCoorLogic(HoleCandidateShareData.EGPScrewCList, refPoint);
            ComputedUtils.SwitchTVHoleCoorType(EGPList);

        }

        //整理 归类孔 标签数据(哪类孔归哪类零件)
        public void TidyUpCoaData()
        {
            List<HoleGroupTag> rpList = CoaGraHoleTagData.CoaReturnPinCList;
            CoaGraHoleTagData.CoaReturnPinCList = rpList.Distinct(new HoleGroupTagComparer()).ToList();

            List<HoleGroupTag> spList = CoaGraHoleTagData.CoaSPScrewCList;
            CoaGraHoleTagData.CoaSPScrewCList = spList.Distinct(new HoleGroupTagComparer()).ToList();

            List<HoleGroupTag> gpList = CoaGraHoleTagData.CoaGPScrewCList;
            CoaGraHoleTagData.CoaGPScrewCList = gpList.Distinct(new HoleGroupTagComparer()).ToList();

            List<HoleGroupTag> fList = CoaGraHoleTagData.CoaFallerScrewCList;
            CoaGraHoleTagData.CoaFallerScrewCList = fList.Distinct(new HoleGroupTagComparer()).ToList();

            List<HoleGroupTag> bigList = CoaGraHoleTagData.CoaBigScrewCList;
            CoaGraHoleTagData.CoaBigScrewCList = bigList.Distinct(new HoleGroupTagComparer()).ToList();

            List<HoleGroupTag> smallList = CoaGraHoleTagData.CoaSmallScrewCList;
            CoaGraHoleTagData.CoaSmallScrewCList = smallList.Distinct(new HoleGroupTagComparer()).ToList();

            //if 导柱 多组 找分中距离最短的那一组
            if (gpList.Count > 0)
            {
                List<double> cdList = gpList.Select(item => item.CD).ToList();
                double mincd = cdList.Min();
                HoleGroupTag gpItem = gpList.Find(item => item.CD == mincd);
                CoaGraHoleTagData.CoaGPScrewCList.Clear();
                CoaGraHoleTagData.CoaGPScrewCList.Add(gpItem);
            }

            //if 拉杆 多组 找分中距离最短的那一组
            if (spList.Count > 0)
            {
                List<double> cdList = spList.Select(item => item.CD).ToList();
                double maxcd = cdList.Max();
                HoleGroupTag spItem = spList.Find(item => item.CD == maxcd);
                CoaGraHoleTagData.CoaSPScrewCList.Clear();
                CoaGraHoleTagData.CoaSPScrewCList.Add(spItem);
            }

            if (rpList.Count > 1)
            {
                for(int i = 0; i < rpList.Count; i++)
                {
                    List<MixedCAD_Point> pointList = rpList[i].CollectionHPList;
                    if(pointList.Count > 0)
                    {
                        List<double> XList = pointList.Select(item => item.CustomerPoint.X).ToList();
                        double minX = XList.Min();
                        double refX = minX - rpList[i].holeArg.Dim;
                        List<BoardSectionItem> BList = AssemblyShareData.ASectionList;
                        int BIndex = BList.FindIndex(item => item.BoardCode.Equals("epBoard") || item.BoardCode.Equals("fpBoard"));
                        BoardSectionItem targetBoard = BList[BIndex];
                        double BSX = targetBoard.OverheadLine.StartPoint.CustomerPoint.X;
                        double BEX = targetBoard.OverheadLine.EndPoint.CustomerPoint.X;
                        Boolean F = BSX < refX;
                        if (!F)
                        {
                            rpList.RemoveAt(i);
                            i++;
                        }
                    }
                }
            }
        }

        //设置 标签孔 分中坐标
        public void TransCoaTigSplitCoorLogic()
        {
            MixedCAD_Point modlHInfo = RecognizeUtils.WholeTopViewData.ModlCenterInfo;
            if (modlHInfo.TransF)
            {
                CAD_Point refPoint = modlHInfo.CustomerPoint;
                List<HoleGroupTag> rpList = CoaGraHoleTagData.CoaReturnPinCList;
                if(rpList.Count > 0)
                    for (int i = 0; i < rpList.Count; i++)
                        CalCoaTagTransToSplit(rpList[i], refPoint);

                List<HoleGroupTag> spList = CoaGraHoleTagData.CoaSPScrewCList;
                if (spList.Count > 0)
                    for (int i = 0; i < spList.Count; i++)
                        CalCoaTagTransToSplit(spList[i], refPoint);

                List<HoleGroupTag> gpList = CoaGraHoleTagData.CoaGPScrewCList;
                if (gpList.Count > 0)
                    for (int i = 0; i < gpList.Count; i++)
                        CalCoaTagTransToSplit(gpList[i], refPoint);

                List<HoleGroupTag> fList = CoaGraHoleTagData.CoaFallerScrewCList;
                if (fList.Count > 0)
                    for (int i = 0; i < fList.Count; i++)
                        CalCoaTagTransToSplit(fList[i], refPoint);

                List<HoleGroupTag> bigList = CoaGraHoleTagData.CoaBigScrewCList;
                if (bigList.Count > 0)
                    for (int i = 0; i < bigList.Count; i++)
                        CalCoaTagTransToSplit(bigList[i], refPoint);

                List<HoleGroupTag> smallList = CoaGraHoleTagData.CoaSmallScrewCList;
                if (smallList.Count > 0)
                    for (int i = 0; i < smallList.Count; i++)
                        CalCoaTagTransToSplit(smallList[i], refPoint);
            }

        }

        //Step 2.1 small 1-3级 回针
        public void Step2_RPWiderRangeSort()
        {
            Boolean LeaveOutF = JudgeItemTagLeaveOut();
            if (LeaveOutF)
            {
                List<HoleGroupTag> operList = GetNotBeContainsTags();
                if (operList.Count > 0)
                {
                    string nowMoldSizeFormat = ATypeGetMoldSizeFormat();
                    int nearSize = GetMNearMoldSize(nowMoldSizeFormat);
                    if (nearSize != -1)
                    {
                        List<BoardSectionItem> epfpBoardList = AssemblyShareData.ASectionList.FindAll(item => item.BoardCode.Equals("epBoard")
                        || item.BoardCode.Equals("fpBoard"));
                        if (epfpBoardList.Count > 0)
                        {
                            List<HoleGroupTag> rpList = CoaGraHoleTagData.CoaReturnPinCList;
                            if (rpList.Count == 0)
                            {
                                double epfpMinX = epfpBoardList.Select(item => item.OverheadLine.StartPoint.TransSplitPoint.X).Min();
                                double epfpMaxX = epfpBoardList.Select(item => item.OverheadLine.EndPoint.TransSplitPoint.X).Max();
                                List<int> scopeRPDimList = new List<int>();
                                List<StandardRP> RPSpoceArgList = GetStep234RPArgList();
                                if (RPSpoceArgList.Count > 0)
                                    scopeRPDimList = RPSpoceArgList.Select(item => item.Dimension).ToList();
                                if (scopeRPDimList.Count > 0)
                                {
                                    for (int i = 0; i < operList.Count; i++)
                                    {
                                        MixedCAD_Point refPoint = operList[i].CollectionHPList.FirstOrDefault();
                                        Boolean fitF = epfpMinX <= refPoint.CustomerPoint.X && refPoint.CustomerPoint.X <= epfpMaxX;
                                        if (fitF)
                                        {
                                            List<double> drawDimList = operList[i].drawDimList;
                                            List<MixedCAD_Point> coorList = operList[i].CollectionHPList;
                                            int drawDimNum = drawDimList.Count;
                                            if (drawDimNum > 0)
                                            {
                                                if (drawDimNum == 1)
                                                {
                                                    if (JudgeRPDim(drawDimList[0], scopeRPDimList))
                                                    {
                                                        List<MixedCAD_Point> tempList = CopyMixedPointList(coorList);
                                                        if (tempList.Count > 0)
                                                        {
                                                            HoleGroupTag fpepTag = new HoleGroupTag();
                                                            fpepTag.CD = GetHoelCD(refPoint.CustomerPoint);
                                                            fpepTag.holeArg.Dim = Math.Round(drawDimList[0], 1);
                                                            fpepTag.drawDimList.AddRange(drawDimList);
                                                            fpepTag.dimList.AddRange(drawDimList);
                                                            fpepTag.CollectionHPList.AddRange(tempList);
                                                            CoaGraHoleTagData.CoaReturnPinCList.Add(fpepTag);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    for (int j = 0; j < drawDimNum - 1; j++)
                                                    {
                                                        int k = j + 1;
                                                        if (JudgeRPDimAndOutDim(drawDimList[j], drawDimList[k], scopeRPDimList))
                                                        {
                                                            List<MixedCAD_Point> tempList = CopyMixedPointList(coorList);
                                                            if (tempList.Count > 0)
                                                            {
                                                                HoleGroupTag fpepTag = new HoleGroupTag();
                                                                fpepTag.CD = GetHoelCD(refPoint.CustomerPoint);
                                                                fpepTag.holeArg.Dim = Math.Round(drawDimList[j], 1);
                                                                fpepTag.drawDimList.AddRange(drawDimList);
                                                                fpepTag.dimList.Add(drawDimList[j]);
                                                                
                                                                fpepTag.CollectionHPList.AddRange(tempList);
                                                                
                                                                CoaGraHoleTagData.CoaReturnPinCList.Add(fpepTag);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        //Step 2.2 GP Big 1  Small 2
        public void Step2_GPWiderRangeSort()
        {
            Boolean LeaveOutF = JudgeItemTagLeaveOut();
            if (LeaveOutF)
            {
                List<HoleGroupTag> operList = GetNotBeContainsTags();
                if (operList.Count > 0)
                {
                    string nowMoldSizeFormat = ATypeGetMoldSizeFormat();
                    int nearSize = GetMNearMoldSize(nowMoldSizeFormat);
                    if (nearSize != -1)
                    {
                        List<HoleGroupTag> gpList = CoaGraHoleTagData.CoaGPScrewCList;
                        if (gpList.Count == 0)
                        {
                            List<int> scopeGPDimList = new List<int>();
                            List<StandardHoleData> StandGPHoleList = new List<StandardHoleData>();
                            StandGPHoleList.AddRange(ParamsConfigData.MoldHoleList.FindAll(item => item.MouldSize == nearSize
                            && item.Item.Equals("导柱")));
                            int? standGPDim = StandGPHoleList.Select(item => item.ItemDim).Distinct().FirstOrDefault();
                            if (standGPDim != null)
                            {
                                List<int> gpDimList = ParamsConfigData.StandardGPList.Select(item => item.Dimension).ToList();
                                gpDimList = gpDimList.OrderBy(item => item).ToList();
                                List<int> smallGPDimList = gpDimList.FindAll(item => item <= (int)standGPDim);
                                //Small 2
                                if (smallGPDimList.Count > 0)
                                {
                                    smallGPDimList = smallGPDimList.OrderByDescending(item => item).ToList();
                                    if(smallGPDimList.Count >= 3)
                                        scopeGPDimList = smallGPDimList.GetRange(0, 3);
                                    else
                                        scopeGPDimList = smallGPDimList.GetRange(0, smallGPDimList.Count);
                                }
                                //Big 1
                                int bigOneIndex = gpDimList.FindIndex(item => item > standGPDim);
                                if (bigOneIndex != -1)
                                    scopeGPDimList.Add(gpDimList[bigOneIndex]);
                            }
                            if (scopeGPDimList.Count > 0)
                            {
                                for (int i = 0; i < operList.Count; i++)
                                {
                                    MixedCAD_Point refPoint = operList[i].CollectionHPList.FirstOrDefault();
                                    List<double> drawDimList = operList[i].drawDimList;
                                    List<MixedCAD_Point> coorList = operList[i].CollectionHPList;
                                    int drawDimNum = drawDimList.Count;
                                    if (drawDimNum > 1)
                                    {
                                        for (int j = 0; j < drawDimNum - 1; j++)
                                        {
                                            int k = j + 1;
                                            if (JudgeGPDimTD(drawDimList[j], drawDimList[k], scopeGPDimList))
                                            {
                                                List<MixedCAD_Point> tempList = CopyMixedPointList(coorList);
                                                if (tempList.Count > 0)
                                                {
                                                    HoleGroupTag gpTag = new HoleGroupTag();
                                                    gpTag.CD = GetHoelCD(refPoint.CustomerPoint);
                                                    gpTag.holeArg.Dim = Math.Round(drawDimList[j], 1);
                                                    gpTag.holeArg.TD = (int)drawDimList[k];
                                                    gpTag.dimList.Add(drawDimList[j]);
                                                    gpTag.dimList.Add(drawDimList[k]);
                                                    gpTag.drawDimList.AddRange(drawDimList);
                                                    gpTag.CollectionHPList.AddRange(tempList);
                                                    CoaGraHoleTagData.CoaGPScrewCList.Add(gpTag);
                                                }
                                            }
                                            if (JudgeGPDimBushSize(drawDimList[j], drawDimList[k], scopeGPDimList))
                                            {
                                                List<MixedCAD_Point> tempList = CopyMixedPointList(coorList);
                                                if (tempList.Count > 0)
                                                {
                                                    HoleGroupTag gpTag = new HoleGroupTag();
                                                    gpTag.CD = GetHoelCD(refPoint.CustomerPoint);
                                                    gpTag.holeArg.Dim = Math.Round(drawDimList[j], 1);
                                                    gpTag.holeArg.BushSize = (int)drawDimList[k];
                                                    gpTag.dimList.Add(drawDimList[j]);
                                                    gpTag.dimList.Add(drawDimList[k]);
                                                    gpTag.drawDimList.AddRange(drawDimList);
                                                    gpTag.CollectionHPList.AddRange(tempList);
                                                    CoaGraHoleTagData.CoaGPScrewCList.Add(gpTag);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (CoaGraHoleTagData.CoaGPScrewCList.Count > 0)
                                StandardShareScopeItemParam.GPSScrewDimList = scopeGPDimList;
                        }
                    }
                }
            }
        }

        //RP Scope DB Arg(Small 1-3 Big 2) 
        public List<StandardRP> GetStep234RPArgList()
        {
            List<StandardRP> ResList = new List<StandardRP>();
            List<int> scopeRPDimList = new List<int>();
            string nowMoldSizeFormat = ATypeGetMoldSizeFormat();
            int nearSize = GetMNearMoldSize(nowMoldSizeFormat);
            if (nearSize != -1)
            {
                List<StandardHoleData> StandRPHoleList = new List<StandardHoleData>();
                StandRPHoleList.AddRange(ParamsConfigData.MoldHoleList.FindAll(item => item.MouldSize == nearSize
                && item.Item.Equals("回针")));
                int? standRPDim = StandRPHoleList.Select(item => item.ItemDim).Distinct().FirstOrDefault();
                if (standRPDim != null)
                {
                    List<int> rpDimList = ParamsConfigData.StandardRPList.Select(item => item.Dimension).ToList();
                    if(rpDimList.Count > 0)
                    {
                        rpDimList = rpDimList.OrderBy(item => item).ToList();
                        List<int> tempRPSmallDimList = rpDimList.FindAll(item => item <= (int)standRPDim);
                        if (tempRPSmallDimList.Count > 0)
                        {
                            tempRPSmallDimList = tempRPSmallDimList.OrderByDescending(item => item).ToList();
                            if(tempRPSmallDimList.Count >= 4)
                                scopeRPDimList = tempRPSmallDimList.GetRange(0, 4);
                            else
                                scopeRPDimList = tempRPSmallDimList.GetRange(0, tempRPSmallDimList.Count);
                        }
                        List<int> tempRPBigDimList = rpDimList.FindAll(item => item > (int)standRPDim);
                        if(tempRPBigDimList.Count > 0)
                        {
                            tempRPBigDimList = tempRPBigDimList.OrderBy(item => item).ToList();
                            if (tempRPBigDimList.Count >= 2)
                                scopeRPDimList.AddRange(tempRPBigDimList.GetRange(0, 2));
                            else
                                scopeRPDimList.AddRange(tempRPBigDimList.GetRange(0, tempRPBigDimList.Count));
                        }
                    }
                }
            }
            if (scopeRPDimList.Count > 0)
            {
                for (int i = 0; i < scopeRPDimList.Count; i++)
                {
                    int targetIndex = ParamsConfigData.StandardRPList.FindIndex(item => item.Dimension == scopeRPDimList[i]);
                    if (targetIndex != -1)
                        ResList.Add(ParamsConfigData.StandardRPList[targetIndex]);
                }
            }
            return ResList;
        }

        //Step 3 By Stand Coor
        public void Step3_GroupByStandCoor()
        {
            string nowMoldSizeFormat = ATypeGetMoldSizeFormat();
            int nearSize = GetMNearMoldSize(nowMoldSizeFormat);
            string CMSeries = "通用";
            string MouldSeries = null;
            if (CADCommonForm.MoldTypeStr.Equals("PP"))
                MouldSeries = "细水口";
            if (CADCommonForm.MoldTypeStr.Equals("SG"))
                MouldSeries = "大水口";
            if (CADCommonForm.MoldTypeStr.Equals("TP"))
                MouldSeries = "简化型";
            List<StandardHoleData> standardHoleList = ParamsConfigData.MoldHoleList.FindAll(item =>
            item.MouldSize == nearSize && (item.MouldSeries.Equals(CMSeries)
            || item.MouldSeries.Equals(MouldSeries)));
            Boolean LeaveOutF = JudgeItemTagLeaveOut();
            if (LeaveOutF)
            {
                List<HoleGroupTag> operList = GetNotBeContainsTags();
                if (operList.Count > 0)
                {
                    List<BoardSectionItem> epfpBoardList = AssemblyShareData.ASectionList.FindAll(item => item.BoardCode.Equals("epBoard")
                        || item.BoardCode.Equals("fpBoard"));
                    if (epfpBoardList.Count > 0)
                    {
                        List<HoleGroupTag> rpList = CoaGraHoleTagData.CoaReturnPinCList;
                        if (rpList.Count == 0)
                        {
                            List<StandardHoleData> rpSHoleList = standardHoleList.FindAll(item => item.Item.Equals("回针")).ToList();
                            if (rpSHoleList.Count > 0)
                            {
                                int standardHNum = rpSHoleList.Count;
                                for (int i = 0; i < operList.Count; i++)
                                {
                                    List<MixedCAD_Point> targetList = operList[i].CollectionHPList;
                                    int confirmNum = 0;
                                    for (int j = 0; j < rpSHoleList.Count; j++)
                                    {
                                        Boolean SF = targetList.FindIndex(item => JudgeHoleAndStandardHoleNearSame(item, rpSHoleList[j])) != -1;
                                        if (SF)
                                            confirmNum++;
                                    }
                                    //Limit Not more than 1 Partial Hole
                                    if (confirmNum >= standardHNum - 1)
                                    {
                                        List<StandardRP> rpScopeArgList = GetStep234RPArgList();
                                        List<double> drawDimList = operList[i].drawDimList;
                                        if (rpScopeArgList.Count > 0 && drawDimList.Count > 0)
                                        {
                                            if (drawDimList.Count == 1)
                                            {
                                                int scopeIndex = rpScopeArgList.FindIndex(item => item.Dimension - 0.02 <= drawDimList[0]
                                                && drawDimList[0] <= item.Dimension + 0.02);
                                                //Print Tag
                                                if (scopeIndex != -1)
                                                {
                                                    List<MixedCAD_Point> coorList = operList[i].CollectionHPList;
                                                    MixedCAD_Point refPoint = operList[i].CollectionHPList.FirstOrDefault();
                                                    List<MixedCAD_Point> tempList = CopyMixedPointList(coorList);
                                                    if (tempList.Count > 0)
                                                    {
                                                        HoleGroupTag fpepTag = new HoleGroupTag();
                                                        fpepTag.CD = GetHoelCD(refPoint.CustomerPoint);
                                                        fpepTag.holeArg.Dim = Math.Round(drawDimList[0], 1);
                                                        fpepTag.drawDimList.AddRange(drawDimList);
                                                        fpepTag.dimList.AddRange(drawDimList);
                                                        fpepTag.CollectionHPList.AddRange(tempList);
                                                        CoaGraHoleTagData.CoaReturnPinCList.Add(fpepTag);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                StandardRP targetSRP = Step34RPDimAndOutDimIndex(drawDimList, rpScopeArgList);
                                                if (targetSRP != null)
                                                {
                                                    List<MixedCAD_Point> coorList = operList[i].CollectionHPList;
                                                    MixedCAD_Point refPoint = operList[i].CollectionHPList.FirstOrDefault();
                                                    List<MixedCAD_Point> tempList = CopyMixedPointList(coorList);
                                                    if (tempList.Count > 0)
                                                    {
                                                        HoleGroupTag fpepTag = new HoleGroupTag();
                                                        fpepTag.CD = GetHoelCD(refPoint.CustomerPoint);
                                                        fpepTag.holeArg.Dim = targetSRP.Dimension;
                                                        fpepTag.holeArg.TD = targetSRP.TD;
                                                        fpepTag.drawDimList.AddRange(drawDimList);
                                                        fpepTag.dimList.AddRange(drawDimList);
                                                        fpepTag.CollectionHPList.AddRange(tempList);
                                                        CoaGraHoleTagData.CoaReturnPinCList.Add(fpepTag);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        //Step 3-4 RP any two Circle Satisfy Judge Dim OutCircle
        public StandardRP Step34RPDimAndOutDimIndex(List<double> drawDimList, List<StandardRP> scopeList)
        {
            StandardRP Res = null;
            List<double> operDrawList = new List<double>(drawDimList);
            if (drawDimList.Count > 0 && scopeList.Count > 0)
            {
                for (int i = 0; i < scopeList.Count; i++)
                {
                    int drawDimIndex = operDrawList.FindIndex(item => scopeList[i].Dimension - 0.02 <= item
                    && item <= scopeList[i].Dimension + 0.02);
                    if (drawDimIndex != -1)
                    {
                        double tempDim = operDrawList[drawDimIndex];
                        operDrawList.RemoveAt(drawDimIndex);
                        int drawTDIndex = operDrawList.FindIndex(item => scopeList[i].TD - 2 <= item
                        && item <= scopeList[i].TD + 2);
                        if (drawTDIndex != -1)
                        {
                            Res = new StandardRP();
                            Res.Dimension = (int)tempDim;
                            Res.TD = (int)operDrawList[drawTDIndex];
                        }
                    }
                }
            }
            return Res;
        }

        //Get Not Allocation Tig Group Hole
        public List<HoleGroupTag> GetNotBeContainsTags()
        {
            List<HoleGroupTag> Res = new List<HoleGroupTag>();
            List<HoleGroupTag> groupList = new List<HoleGroupTag>();
            Dictionary<string, List<ConSpeCircle>> CircleDic = RecognizeUtils.WholeTopViewData.CircleDic;
            List<string> Keys = CircleDic.Keys.ToList();
            for (int i = 0; i < Keys.Count; i++)
            {
                List<HoleGroupTag> tempGroup = new List<HoleGroupTag>();
                ConSpeCircle firstItem = CircleDic[Keys[i]].First();
                List<double> tempDimList = firstItem.DimList;
                List<MixedCAD_Point> tempList = new List<MixedCAD_Point>();
                for (int j = 0; j < CircleDic[Keys[i]].Count; j++)
                {
                    MixedCAD_Point Item = new MixedCAD_Point();
                    Item.CustomerPoint.X = CircleDic[Keys[i]][j].CustomerConHPoint.X;
                    Item.CustomerPoint.Y = CircleDic[Keys[i]][j].CustomerConHPoint.Y;
                    tempList.Add(Item);
                }
                if (tempList.Count > 0)
                {
                    HoleGroupTag tempTag = new HoleGroupTag();
                    tempTag.CD = GetHoelCD(firstItem.ConRefPoint);
                    tempTag.drawDimList.AddRange(tempDimList);
                    tempTag.CollectionHPList.AddRange(tempList);
                    tempGroup.Add(tempTag);
                }
                groupList.AddRange(tempGroup);
            }
            if (groupList.Count > 0)
            {
                //Step 1 all Item Tag
                List<HoleGroupTag> famliyList = GetFirstStageItemFamily();
                for (int i = 0; i < groupList.Count; i++)
                {
                    Boolean NoContainsF = NoBeContainsTagFamily(groupList[i], famliyList);
                    if (NoContainsF)
                        Res.Add(groupList[i]);
                }
            }
            return Res;
        }


        public List<MixedCAD_Point> CopyMixedPointList(List<MixedCAD_Point> operList)
        {
            List<MixedCAD_Point> ResList = new List<MixedCAD_Point>();
            for (int j = 0; j < operList.Count; j++)
            {
                MixedCAD_Point Item = new MixedCAD_Point();
                Item.CustomerPoint.X = operList[j].CustomerPoint.X;
                Item.CustomerPoint.Y = operList[j].CustomerPoint.Y;
                Item.TransSplitPoint.X = operList[j].TransSplitPoint.X;
                Item.TransSplitPoint.Y = operList[j].TransSplitPoint.Y;
                ResList.Add(Item);
            }
            return ResList;
        }

        //Judge Need Rec Item Hole Tag Exist Omit
        public Boolean JudgeItemTagLeaveOut()
        {
            List<HoleGroupTag> rpList = CoaGraHoleTagData.CoaReturnPinCList;
            List<HoleGroupTag> spList = CoaGraHoleTagData.CoaSPScrewCList;
            List<HoleGroupTag> gpList = CoaGraHoleTagData.CoaGPScrewCList;
            List<HoleGroupTag> fList = CoaGraHoleTagData.CoaFallerScrewCList;
            List<HoleGroupTag> bigList = CoaGraHoleTagData.CoaBigScrewCList;
            List<HoleGroupTag> smallList = CoaGraHoleTagData.CoaSmallScrewCList;
            Boolean F1 = rpList.Count == 0;
            Boolean F2 = spList.Count == 0;
            Boolean F3 = gpList.Count == 0;
            Boolean F4 = fList.Count == 0;
            Boolean F5 = bigList.Count == 0;
            Boolean F6 = smallList.Count == 0;
            return F1 || F2 || F3 || F4 || F5 || F6;
        }

        //Get Step 1 has Rec Item Hole Tag 
        public List<HoleGroupTag> GetFirstStageItemFamily()
        {
            List<HoleGroupTag> ResList = new List<HoleGroupTag>();
            List<HoleGroupTag> rpList = CoaGraHoleTagData.CoaReturnPinCList;
            List<HoleGroupTag> spList = CoaGraHoleTagData.CoaSPScrewCList;
            List<HoleGroupTag> gpList = CoaGraHoleTagData.CoaGPScrewCList;
            List<HoleGroupTag> fList = CoaGraHoleTagData.CoaFallerScrewCList;
            List<HoleGroupTag> bigList = CoaGraHoleTagData.CoaBigScrewCList;
            List<HoleGroupTag> smallList = CoaGraHoleTagData.CoaSmallScrewCList;
            ResList.AddRange(rpList);
            ResList.AddRange(spList);
            ResList.AddRange(gpList);
            ResList.AddRange(fList);
            ResList.AddRange(bigList);
            ResList.AddRange(smallList);
            return ResList;
        }

        public Boolean NoBeContainsTagFamily(HoleGroupTag argTagItem, List<HoleGroupTag> referTagList)
        {
            return referTagList.FindIndex(item => CheckContainsFamliyLogic(argTagItem, item)) == -1;
        }

        public static void GetStandardItemSpe()
        {
            List<LabourSingleItem> ResList = new List<LabourSingleItem>();
            string NowMoldSize = ComputedUtils.ATypeGetMoldSizeFormat();
            int nearSize = int.Parse(NowMoldSize);
            string CommonMouldSeries = "通用";
            string MouldSeries = null;
            if (CADCommonForm.MoldTypeStr.Equals("PP"))
                MouldSeries = "细水口";
            if (CADCommonForm.MoldTypeStr.Equals("SG"))
                MouldSeries = "大水口";
            if (CADCommonForm.MoldTypeStr.Equals("TP"))
                MouldSeries = "简化型";
            List<StandardHoleData> DBSHList = ParamsConfigData.MoldHoleList.FindAll(item =>
             item.MouldSize == nearSize &&
             (item.MouldSeries.Equals(CommonMouldSeries) || item.MouldSeries.Equals(MouldSeries)));
            string CategoryStr = CADCommonForm.CategoryStr;
            List<StandardSeriesRelItem> StandardMItemList = ParamsConfigData.StandardBoardRelItemList.FindAll(item => item.MouldSeries.Equals(CategoryStr)).ToList();

            if (StandardMItemList.Count >0)
            {
                for (int i = 0; i < StandardMItemList.Count; i++)
                {
                    StandardSeriesRelItem target = StandardMItemList[i];
                    LabourSingleItem temp = new LabourSingleItem();
                    temp.ItemCode = target.ItemCode;
                    temp.ItemName = target.ItemName;
                    ResList.Add(temp);
                }
            }
            if(ResList.Count > 0)
            {
                if(DBSHList.Count > 0)
                {
                    int SIndex = ResList.FindIndex(item => item.ItemCode.Equals("BottomPanelScrew"));
                    if(SIndex != -1)
                    {
                        int SNum = DBSHList.FindAll(item => item.Item.Equals("小螺丝")).Count;
                        Boolean KF = ParamsConfigData.RecommendDimDic.ContainsKey("底板螺丝");
                        ResList[SIndex].ItemNum = SNum;
                        if (KF )
                        {
                            double bpsDim = ParamsConfigData.RecommendDimDic["底板螺丝"];
                            ResList[SIndex].ItemDim = bpsDim;
                        }
                    }

                    SIndex = ResList.FindIndex(item => item.ItemCode.Equals("TopPanelScrew"));
                    if(SIndex != -1)
                    {
                        int SNum = DBSHList.FindAll(item => item.Item.Equals("大螺丝")).Count;
                        Boolean KF = ParamsConfigData.RecommendDimDic.ContainsKey("面板螺丝");
                        ResList[SIndex].ItemNum = SNum;
                        if (KF)
                        {
                            double bpsDim = ParamsConfigData.RecommendDimDic["面板螺丝"];
                            ResList[SIndex].ItemDim = bpsDim;
                        }
                    }

                    SIndex = ResList.FindIndex(item => item.ItemCode.Equals("SpaceBlockScrew"));
                    if(SIndex != -1)
                    {
                        int SNum = DBSHList.FindAll(item => item.Item.Equals("大螺丝")).Count;
                        Boolean KF = ParamsConfigData.RecommendDimDic.ContainsKey("方铁螺丝");
                        ResList[SIndex].ItemNum = SNum;
                        if (KF)
                        {
                            double bpsDim = ParamsConfigData.RecommendDimDic["方铁螺丝"];
                            ResList[SIndex].ItemDim = bpsDim;
                        }
                    }

                    SIndex = ResList.FindIndex(item => item.ItemCode.Equals("PinBoardScrew"));
                    if(SIndex != -1)
                    {
                        int SNum = DBSHList.FindAll(item => item.Item.Equals("针板螺丝")).Count;
                        Boolean KF = ParamsConfigData.RecommendDimDic.ContainsKey("针板螺丝");
                        ResList[SIndex].ItemNum = SNum;
                        if (KF)
                        {
                            double bpsDim = ParamsConfigData.RecommendDimDic["针板螺丝"];
                            ResList[SIndex].ItemDim = bpsDim;
                        }
                    }

                   SIndex = ResList.FindIndex(item => item.ItemCode.Equals("ReturnPin"));
                   if(SIndex != -1)
                    {
                        int SNum = DBSHList.FindAll(item => item.Item.Equals("回针")).Count;
                        Boolean KF = ParamsConfigData.RecommendDimDic.ContainsKey("回针");
                        ResList[SIndex].ItemNum = SNum;
                        if (KF)
                        {
                            double bpsDim = ParamsConfigData.RecommendDimDic["回针"];
                            ResList[SIndex].ItemDim = bpsDim;
                        }
                    }

                    SIndex = ResList.FindIndex(item => item.ItemCode.Equals("GuidePin"));
                    if (SIndex != -1)
                    {
                        int SNum = DBSHList.FindAll(item => item.Item.Equals("导柱")).Count;
                        Boolean KF = ParamsConfigData.RecommendDimDic.ContainsKey("导柱");
                        ResList[SIndex].ItemNum = SNum;
                        if (KF)
                        {
                            double bpsDim = ParamsConfigData.RecommendDimDic["导柱"];
                            ResList[SIndex].ItemDim = bpsDim;
                        }
                    }

                    SIndex = ResList.FindIndex(item => item.ItemCode.Equals("SupportPin"));
                    if(SIndex != -1)
                    {
                        int SNum = DBSHList.FindAll(item => item.Item.Equals("拉杆")).Count;
                        Boolean KF = ParamsConfigData.RecommendDimDic.ContainsKey("拉杆");
                        ResList[SIndex].ItemNum = SNum;
                        if (KF)
                        {
                            double bpsDim = ParamsConfigData.RecommendDimDic["拉杆"];
                            ResList[SIndex].ItemDim = bpsDim;
                        }
                    }

                }
            }

        }

        //Item Famliy Conditions CD
        public Boolean CheckContainsFamliyLogic(HoleGroupTag tag1, HoleGroupTag tag2)
        {
            Boolean F2 = tag1.CD == tag2.CD;
            return F2;
        }

        //Calculate Item Hole All Arg
        public void DRPartOfHoleArg()
        {
            List<int> GPDimList = StandardShareScopeItemParam.GPSScrewDimList;
            List<HoleGroupTag> gpList = CoaGraHoleTagData.CoaGPScrewCList;
            if (gpList.Count > 0)
            {
                for (int i = 0; i < gpList.Count; i++)
                {
                    if (gpList[i].holeArg.Dim != 0)
                    {
                        StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.Dimension - 0.2 <= gpList[i].holeArg.Dim
                        && gpList[i].holeArg.Dim <= item.Dimension + 0.2);
                        if (ScrewItem != null)
                        {
                            if (gpList[i].holeArg.TD == 0)
                                gpList[i].holeArg.TD = ScrewItem.TD;
                            if (gpList[i].holeArg.BushTD == 0)
                                gpList[i].holeArg.BushTD = ScrewItem.BushTD;
                            if (gpList[i].holeArg.BushSize == 0)
                                gpList[i].holeArg.BushSize = ScrewItem.BushSize;
                            if (gpList[i].holeArg.BK == 0)
                                gpList[i].holeArg.BK = ScrewItem.BK_1;
                            continue;
                        }
                    }
                    else
                    {
                        if (gpList[i].holeArg.TD != 0)
                        {
                            StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.TD - 1 <= gpList[i].holeArg.TD
                            && gpList[i].holeArg.TD <= item.TD + 1);
                            if (ScrewItem != null)
                            {
                                gpList[i].holeArg.Dim = ScrewItem.Dimension;
                                if (gpList[i].holeArg.BushSize == 0)
                                    gpList[i].holeArg.BushSize = ScrewItem.BushSize;
                                if (gpList[i].holeArg.BushTD == 0)
                                    gpList[i].holeArg.BushTD = ScrewItem.BushTD;
                                if (gpList[i].holeArg.BK == 0)
                                    gpList[i].holeArg.BK = ScrewItem.BK_1;
                                continue;
                            }
                        }
                        if (gpList[i].holeArg.BushTD != 0)
                        {
                            StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.BushTD - 1 <= gpList[i].holeArg.BushTD
                            && gpList[i].holeArg.BushTD <= item.BushTD + 1);
                            if (ScrewItem != null)
                            {
                                gpList[i].holeArg.Dim = ScrewItem.Dimension;
                                if (gpList[i].holeArg.BushSize == 0)
                                    gpList[i].holeArg.BushSize = ScrewItem.BushSize;
                                if (gpList[i].holeArg.BushTD == 0)
                                    gpList[i].holeArg.BushTD = ScrewItem.BushTD;
                                if (gpList[i].holeArg.BK == 0)
                                    gpList[i].holeArg.BK = ScrewItem.BK_1;
                                continue;
                            }
                        }
                        if (gpList[i].holeArg.BushSize != 0)
                        {
                            StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.BushSize - 2 <= gpList[i].holeArg.BushSize
                            && gpList[i].holeArg.BushSize <= item.BushSize + 2);
                            if (ScrewItem != null)
                            {
                                gpList[i].holeArg.Dim = ScrewItem.Dimension;
                                if (gpList[i].holeArg.TD == 0)
                                    gpList[i].holeArg.TD = ScrewItem.TD;
                                if (gpList[i].holeArg.BushTD == 0)
                                    gpList[i].holeArg.BushTD = ScrewItem.BushTD;
                                if (gpList[i].holeArg.BK == 0)
                                    gpList[i].holeArg.BK = ScrewItem.BK_1;
                                continue;
                            }
                        }
                    }
                }
            }

            List<int> SPDimList = StandardShareScopeItemParam.SPScrewDimList;
            List<HoleGroupTag> spList = CoaGraHoleTagData.CoaSPScrewCList;
            for (int i = 0; i < spList.Count; i++)
            {
                if (spList[i].holeArg.Dim != 0)
                {
                    int DimIndex = SPDimList.FindIndex(item => item - 0.2 <= spList[i].holeArg.Dim
                    && spList[i].holeArg.Dim <= item + 0.2);
                    if (DimIndex != -1)
                    {
                        StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.Dimension == SPDimList[DimIndex]);
                        if (spList[i].holeArg.TD == 0)
                            spList[i].holeArg.TD = ScrewItem.TD;
                        if (spList[i].holeArg.BushTD == 0)
                            spList[i].holeArg.BushTD = ScrewItem.BushTD;
                        if (spList[i].holeArg.BushSize == 0)
                            spList[i].holeArg.BushSize = ScrewItem.BushSize;
                        if (spList[i].holeArg.BK == 0)
                            spList[i].holeArg.BK = ScrewItem.BK_2;
                        continue;
                    }
                }
                else
                {
                    if (spList[i].holeArg.TD != 0)
                    {
                        StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.TD - 1 <= spList[i].holeArg.TD
                        && spList[i].holeArg.TD <= item.TD + 1);
                        if (ScrewItem != null)
                        {
                            spList[i].holeArg.Dim = ScrewItem.Dimension;
                            if (spList[i].holeArg.BushSize == 0)
                                spList[i].holeArg.BushSize = ScrewItem.BushSize;
                            if (spList[i].holeArg.BushTD == 0)
                                spList[i].holeArg.BushTD = ScrewItem.BushTD;
                            if (spList[i].holeArg.BK == 0)
                                spList[i].holeArg.BK = ScrewItem.BK_2;
                            continue;
                        }
                    }
                    if (spList[i].holeArg.BushTD != 0)
                    {
                        StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.BushTD - 1 <= spList[i].holeArg.BushTD
                        && spList[i].holeArg.BushTD <= item.BushTD + 1);
                        if (ScrewItem != null)
                        {
                            spList[i].holeArg.Dim = ScrewItem.Dimension;
                            if (spList[i].holeArg.BushSize == 0)
                                spList[i].holeArg.BushSize = ScrewItem.BushSize;
                            if (spList[i].holeArg.BushTD == 0)
                                spList[i].holeArg.BushTD = ScrewItem.BushTD;
                            if (spList[i].holeArg.BK == 0)
                                spList[i].holeArg.BK = ScrewItem.BK_2;
                            continue;
                        }
                    }
                    if (spList[i].holeArg.BushSize != 0)
                    {
                        StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.BushSize - 2 <= spList[i].holeArg.BushSize
                        && spList[i].holeArg.BushSize <= item.BushSize + 2);
                        if (ScrewItem != null)
                        {
                            spList[i].holeArg.Dim = ScrewItem.Dimension;
                            if (spList[i].holeArg.TD == 0)
                                spList[i].holeArg.TD = ScrewItem.TD;
                            if (spList[i].holeArg.BushTD == 0)
                                spList[i].holeArg.BushTD = ScrewItem.BushTD;
                            if (spList[i].holeArg.BK == 0)
                                spList[i].holeArg.BK = ScrewItem.BK_2;
                            continue;
                        }
                    }
                    if (spList[i].holeArg.BK != 0)
                    {
                        StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.BK_2 - 5 <= spList[i].holeArg.BK
                        && spList[i].holeArg.BK <= item.BK_2 + 2);
                        if (ScrewItem != null)
                        {
                            spList[i].holeArg.Dim = ScrewItem.Dimension;
                            if (spList[i].holeArg.TD == 0)
                                spList[i].holeArg.TD = ScrewItem.TD;
                            if (spList[i].holeArg.BushTD == 0)
                                spList[i].holeArg.BushTD = ScrewItem.BushTD;
                            if (spList[i].holeArg.BushSize == 0)
                                spList[i].holeArg.BushSize = ScrewItem.BushSize;
                        }
                    }
                }
            }

            List<HoleGroupTag> rpList = CoaGraHoleTagData.CoaReturnPinCList;
            if (rpList.Count > 0)
            {
                for (int i = 0; i < rpList.Count; i++)
                {
                    StandardRP ScrewItem = ParamsConfigData.StandardRPList.Find(item =>
                    item.Dimension - 0.02 <= rpList[i].holeArg.Dim
                    && rpList[i].holeArg.Dim <= item.Dimension + 0.02);
                    if (ScrewItem != null && rpList[i].holeArg.TD == 0)
                        rpList[i].holeArg.TD = ScrewItem.TD;
                }
            }

            List<int> BigDimList = StandardShareScopeItemParam.BigSScrewDimList;
            List<HoleGroupTag> bigList = CoaGraHoleTagData.CoaBigScrewCList;
            if (BigDimList.Count > 0)
            {
                for (int i = 0; i < bigList.Count; i++)
                {
                    int CDim = BigDimList.Find(item => item - 0.02 <= bigList[i].holeArg.Dim
                    && bigList[i].holeArg.Dim <= item + 0.02);
                    StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                    if (ScrewItem != null && bigList[i].holeArg.TD == 0)
                        bigList[i].holeArg.TD = (int)ScrewItem.TD;
                }
            }

            List<int> FallerDimList = StandardShareScopeItemParam.FallerSScrewDimList;
            List<HoleGroupTag> fList = CoaGraHoleTagData.CoaFallerScrewCList;
            if (fList.Count > 0)
            {
                for (int i = 0; i < fList.Count; i++)
                {
                    int CDim = FallerDimList.Find(item => item - 0.02 <= fList[i].holeArg.Dim
                    && fList[i].holeArg.Dim <= item + 0.02);
                    StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                    if (ScrewItem != null && fList[i].holeArg.TD == 0)
                        fList[i].holeArg.TD = (int)ScrewItem.TD;
                }
            }

            List<int> SmallDimList = StandardShareScopeItemParam.SmallSScrewDimList;
            List<HoleGroupTag> smallList = CoaGraHoleTagData.CoaSmallScrewCList;
            if (smallList.Count > 0)
            {
                for (int i = 0; i < smallList.Count; i++)
                {
                    int CDim = SmallDimList.Find(item => item - 0.02 <= smallList[i].holeArg.Dim
                    && smallList[i].holeArg.Dim <= item + 0.02);
                    StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                    if (ScrewItem != null && smallList[i].holeArg.TD == 0)
                        smallList[i].holeArg.TD = (int)ScrewItem.TD;
                }
            }

        }

        public void SetItemHoleDataByTag()
        {
            MixedCAD_Point modlHInfo =  RecognizeUtils.WholeTopViewData.ModlCenterInfo;
            CAD_Point refPoint = modlHInfo.CustomerPoint;
            //GP
            List<HoleGroupTag> gpList = CoaGraHoleTagData.CoaGPScrewCList;
            //When Hole Num == 8 Special treatment
            if (gpList.Count > 0)
            {
                HoleGroupTag targetItem = gpList[0];
                if (targetItem.CollectionHPList.Count == 8)
                    targetItem.CollectionHPList = GPHolePointCDDissComparator(refPoint, targetItem.CollectionHPList);
                List<MixedCAD_Point> pList = targetItem.CollectionHPList;
                for (int i = 0; i < pList.Count; i++)
                {
                    ScrewHole Item = new ScrewHole();
                    Item = (ScrewHole)ConvertUtils.DeepCopyObject(targetItem.holeArg);
                    Item.CenterPoint = new MixedCAD_Point();
                    Item.CenterPoint.CustomerPoint.X = pList[i].CustomerPoint.X;
                    Item.CenterPoint.CustomerPoint.Y = pList[i].CustomerPoint.Y;
                    HoleCandidateShareData.GPScrewCList.Add(Item);
                }
            }
            //SP
            List<HoleGroupTag> spList = CoaGraHoleTagData.CoaSPScrewCList;
            if (spList.Count > 0)
            {
                HoleGroupTag targetItem = spList[0];
                if (targetItem.CollectionHPList.Count == 8)
                    targetItem.CollectionHPList = SPHolePointCDDissComparator(refPoint, targetItem.CollectionHPList);
                List<MixedCAD_Point> pList = targetItem.CollectionHPList;
                for (int i = 0; i < pList.Count; i++)
                {
                    ScrewHole Item = new ScrewHole();
                    Item = (ScrewHole)ConvertUtils.DeepCopyObject(targetItem.holeArg);
                    Item.CenterPoint = new MixedCAD_Point();
                    Item.CenterPoint.CustomerPoint.X = pList[i].CustomerPoint.X;
                    Item.CenterPoint.CustomerPoint.Y = pList[i].CustomerPoint.Y;
                    HoleCandidateShareData.SPScrewCList.Add(Item);
                }
            }

            List<HoleGroupTag> rpList = CoaGraHoleTagData.CoaReturnPinCList;
            if (rpList.Count > 0)
            {
                for (int i = 0; i < rpList.Count; i++)
                {
                    List<MixedCAD_Point> rpholeList = rpList[i].CollectionHPList;
                    for (int j = 0; j < rpholeList.Count; j++)
                    {
                        ScrewHole Item = new ScrewHole();
                        Item = (ScrewHole)ConvertUtils.DeepCopyObject(rpList[i].holeArg);
                        Item.CenterPoint = new MixedCAD_Point();
                        Item.CenterPoint.CustomerPoint.X = rpholeList[j].CustomerPoint.X;
                        Item.CenterPoint.CustomerPoint.Y = rpholeList[j].CustomerPoint.Y;
                        HoleCandidateShareData.ReturnPinCList.Add(Item);
                    }
                }
            }

            List<HoleGroupTag> epfpList = CoaGraHoleTagData.CoaFallerScrewCList;
            if (epfpList.Count > 0)
            {
                for (int i = 0; i < epfpList.Count; i++)
                {
                    List<MixedCAD_Point> epfpholeList = epfpList[i].CollectionHPList;
                    for (int j = 0; j < epfpholeList.Count; j++)
                    {
                        ScrewHole Item = new ScrewHole();
                        Item = (ScrewHole)ConvertUtils.DeepCopyObject(epfpList[i].holeArg);
                        Item.CenterPoint = new MixedCAD_Point();
                        Item.CenterPoint.CustomerPoint.X = epfpholeList[j].CustomerPoint.X;
                        Item.CenterPoint.CustomerPoint.Y = epfpholeList[j].CustomerPoint.Y;
                        HoleCandidateShareData.FallerScrewCList.Add(Item);
                    }
                }
            }

            List<HoleGroupTag> bigList = CoaGraHoleTagData.CoaBigScrewCList;
            if (bigList.Count > 0)
            {
                for (int i = 0; i < bigList.Count; i++)
                {
                    List<MixedCAD_Point> bigholeList = bigList[i].CollectionHPList;
                    for (int j = 0; j < bigholeList.Count; j++)
                    {
                        ScrewHole Item = new ScrewHole();
                        Item = (ScrewHole)ConvertUtils.DeepCopyObject(bigList[i].holeArg);
                        Item.CenterPoint = new MixedCAD_Point();
                        Item.CenterPoint.CustomerPoint.X = bigholeList[j].CustomerPoint.X;
                        Item.CenterPoint.CustomerPoint.Y = bigholeList[j].CustomerPoint.Y;
                        HoleCandidateShareData.BigScrewCList.Add(Item);
                    }
                }
            }

            List<HoleGroupTag> smallList = CoaGraHoleTagData.CoaSmallScrewCList;
            if (smallList.Count > 0)
            {
                for (int i = 0; i < smallList.Count; i++)
                {
                    List<MixedCAD_Point> smallholeList = smallList[i].CollectionHPList;
                    for (int j = 0; j < smallholeList.Count; j++)
                    {
                        ScrewHole Item = new ScrewHole();
                        Item = (ScrewHole)ConvertUtils.DeepCopyObject(smallList[i].holeArg);
                        Item.CenterPoint = new MixedCAD_Point();
                        Item.CenterPoint.CustomerPoint.X = smallholeList[j].CustomerPoint.X;
                        Item.CenterPoint.CustomerPoint.Y = smallholeList[j].CustomerPoint.Y;
                        HoleCandidateShareData.SmallScrewCList.Add(Item);
                    }
                }
            }

            ComputedUtils.CalTViewHoleSplitCoorLogic(HoleCandidateShareData.BigScrewCList,refPoint);
            ComputedUtils.CalTViewHoleSplitCoorLogic(HoleCandidateShareData.SmallScrewCList, refPoint);
            ComputedUtils.CalTViewHoleSplitCoorLogic(HoleCandidateShareData.SPScrewCList, refPoint);
            ComputedUtils.CalTViewHoleSplitCoorLogic(HoleCandidateShareData.GPScrewCList, refPoint);
            ComputedUtils.CalTViewHoleSplitCoorLogic(HoleCandidateShareData.EGPScrewCList, refPoint);
            ComputedUtils.CalTViewHoleSplitCoorLogic(HoleCandidateShareData.FallerScrewCList, refPoint);
            ComputedUtils.CalTViewHoleSplitCoorLogic(HoleCandidateShareData.ReturnPinCList, refPoint);

            SetScrewHoleWithFPos(HoleCandidateShareData.BigScrewCList);
            SetScrewHoleWithFPos(HoleCandidateShareData.SmallScrewCList);
            SetScrewHoleWithFPos(HoleCandidateShareData.SPScrewCList);
            SetScrewHoleWithFPos(HoleCandidateShareData.GPScrewCList);
            SetScrewHoleWithFPos(HoleCandidateShareData.FallerScrewCList);
            SetScrewHoleWithFPos(HoleCandidateShareData.ReturnPinCList);
        }

        //Judge Fangtie Exist Stand Up X
        public Boolean JudgeFangtieAreaExitStandUpX(List<MixedCAD_Line> VLines, double StandX, double FMaxY, double FMinY)
        {
            Boolean Res = false;
            List<MixedCAD_Line> StandXVList = VLines.FindAll(item => item.StartPoint.CustomerPoint.X - 0.1 <= StandX
            && StandX <= item.StartPoint.CustomerPoint.X + 0.1).ToList();
            if (StandXVList.Count > 0)
            {
                int FIndex1 = StandXVList.FindIndex(item => FYincludeStrategyA(item, FMaxY, FMinY));
                if (FIndex1 != -1)
                    return true;
            }
            return Res;
        }

        //Fangtie Y Contains
        public Boolean FYincludeStrategyA(MixedCAD_Line targetLine, double FMaxY, double FMinY)
        {

            Boolean Res = false;
            double? MinY;
            double? MaxY;

            if (targetLine.SPChamferFlag)
            {
                double SCLY1 = targetLine.SCLine.StartPoint.CustomerPoint.Y;
                double SCLY2 = targetLine.SCLine.EndPoint.CustomerPoint.Y;
                MaxY = SCLY1 > SCLY2 ? SCLY1 : SCLY2;
            }
            else
                MaxY = targetLine.StartPoint.CustomerPoint.Y;

            if (targetLine.EPChamferFlag)
            {
                double ECLY1 = targetLine.ECLine.StartPoint.CustomerPoint.Y;
                double ECLY2 = targetLine.ECLine.EndPoint.CustomerPoint.Y;
                MinY = ECLY1 < ECLY2 ? ECLY1 : ECLY2;
            }
            else
                MinY = targetLine.EndPoint.CustomerPoint.Y;

            if (MaxY != null && MinY != null)
            {
                Boolean SceneAF1 = (double)MaxY > FMaxY;
                Boolean SceneAF2 = FMinY <= (double)MinY && (double)MinY <= FMaxY;
                if (SceneAF1 && SceneAF2)
                    return true;

                Boolean SceneBF1 = FMinY <= (double)MaxY && (double)MaxY <= FMaxY;
                Boolean SceneBF2 = (double)MinY < FMinY;
                if (SceneBF1 && SceneBF2)
                    return true;

                Boolean SceneCF1 = (double)MaxY > FMaxY;
                Boolean SceneCF2 = (double)MinY < FMinY;
                if (SceneCF1 && SceneCF2)
                    return true;

                Boolean SceneDF1 = (double)MaxY <= FMaxY;
                Boolean SceneDF2 = (double)MinY >= FMinY;
                if (SceneDF1 && SceneDF2)
                    return true;
            }

            return Res;
        }

        //自动模式根据A/B板 宽长 配出型号格式 300 350 -> 3050
        public static string ATypeGetMoldSizeFormat()
        {
            string moldSize = string.Empty;
            string nowLStr = string.Empty;
            string nowWStr = MoldBaseShare.Width.ToString().Substring(0, 2);
            double.TryParse(nowWStr, out double Wformat);
            if (Wformat <= 60)
                nowLStr = MoldBaseShare.Length.ToString().Substring(0, 2);
            else
                nowLStr = MoldBaseShare.Length.ToString().Substring(0, 3);
            moldSize = nowWStr + nowLStr;
            return moldSize;
        }

        //取得推荐大小
        public static int GetMNearMoldSize(string MoldBaseShare)
        {
            int res = -1;
            Boolean F = int.TryParse(MoldBaseShare, out int number);
            if (F)
            {
                res = Convert.ToInt32(MoldBaseShare);
                List<int> MouldSizeList = ParamsConfigData.MoldHoleList.Select(item => item.MouldSize)
                    .Distinct().OrderBy(item => item).ToList();
                if (MouldSizeList.Count > 0)
                {
                    Dictionary<int, List<int>> fitMouldDic = new Dictionary<int, List<int>>();
                    for (int i = 0; i < MouldSizeList.Count; i++)
                    {
                        string MouldStr = MouldSizeList[i].ToString();
                        string widthStr = MouldStr.Substring(0, 2);
                        string lengthStr = MouldStr.Substring(2, MouldStr.Length - 2);
                        int widthSize = int.Parse(widthStr);
                        int lengthSize = int.Parse(lengthStr);
                        if (!fitMouldDic.ContainsKey(widthSize))
                        {
                            List<int> tLList = new List<int>();
                            tLList.Add(lengthSize);
                            fitMouldDic.Add(widthSize, tLList);
                        }
                        else
                            fitMouldDic[widthSize].Add(lengthSize);
                    }
                    if (fitMouldDic.Count > 0)
                    {
                        string nowWStr = MoldBaseShare.Substring(0, 2);
                        Boolean WF = int.TryParse(nowWStr, out int resultW);
                        if (WF)
                        {
                            //合适的宽 长
                            int? fitW = null;
                            int? fitL = null;
                            int nowWidth = int.Parse(nowWStr);
                            List<int> widthKeyList = fitMouldDic.Keys.ToList();
                            int accordWIndex = widthKeyList.FindIndex(item => item == nowWidth);
                            if (accordWIndex != -1)
                                fitW = widthKeyList[accordWIndex];
                            else
                            {
                                //上下进行比较 取靠近的
                                int PerWIndex = widthKeyList.FindLastIndex(item => item < nowWidth);
                                int NextWIndex = widthKeyList.FindIndex(item => item > nowWidth);
                                if (PerWIndex != -1 && NextWIndex != -1)
                                {
                                    int PerW = widthKeyList[PerWIndex];
                                    int NextW = widthKeyList[NextWIndex];
                                    //差值
                                    int DiffPerW = Math.Abs(PerW - nowWidth);
                                    int DiffNextW = Math.Abs(NextW - nowWidth);
                                    //在中间比如33 35 值是34 取35
                                    if (DiffPerW == DiffNextW)
                                        fitW = NextW;
                                    //取靠近
                                    else
                                        fitW = DiffPerW < DiffNextW ? PerW : NextW;
                                }
                            }
                            if (fitW != null)
                            {
                                string nowLStr = null;
                                if (fitW <= 60)
                                    nowLStr = MoldBaseShare.Substring(2, 2);
                                else
                                    nowLStr = MoldBaseShare.Substring(2, 3);
                                Boolean LF = int.TryParse(nowLStr, out int resultL);
                                if (LF)
                                {
                                    int nowLength = int.Parse(nowLStr);
                                    List<int> lengthScopeList = fitMouldDic[(int)fitW];
                                    if (lengthScopeList.Count > 0)
                                    {
                                        int accordLIndex = lengthScopeList.FindIndex(item => item == nowLength);
                                        if (accordLIndex != -1)
                                            fitL = lengthScopeList[accordLIndex];
                                        else
                                        {
                                            int PerL = lengthScopeList.FindLast(item => item < nowLength);
                                            int NextL = lengthScopeList.Find(item => item > nowLength);
                                            int DiffPerL = Math.Abs(PerL - nowLength);
                                            int DiffNextL = Math.Abs(NextL - nowLength);
                                            if (DiffPerL == DiffNextL)
                                                fitL = NextL;
                                            else
                                                fitL = DiffPerL < DiffNextL ? PerL : NextL;
                                        }
                                    }
                                }
                                if (fitL != null)
                                {
                                    int NowMoldSize = int.Parse(fitW.ToString() + fitL.ToString());
                                    int MouldIndex = MouldSizeList.FindIndex(item => item == NowMoldSize);
                                    if (MouldIndex != -1)
                                        res = MouldSizeList[MouldIndex];
                                }
                            }
                        }
                    }
                }
            }
            return res;
        }

        public static Boolean EqualCenterPointDim(ScrewHole originItem, ScrewHole targetItem)
        {
            Boolean CenterXFlag = originItem.CenterPoint.CustomerPoint.X == targetItem.CenterPoint.CustomerPoint.X;
            Boolean CenterYFlag = originItem.CenterPoint.CustomerPoint.Y == targetItem.CenterPoint.CustomerPoint.Y;
            Boolean DimFlag = originItem.Dim == targetItem.Dim;
            return CenterXFlag && CenterYFlag && DimFlag;
        }

        public static Boolean RPBKADimOrBushSizeSameF(ScrewHole BKItem, ScrewHole NoBKItem)
        {
            Boolean XF = BKItem.CenterPoint.CustomerPoint.X == NoBKItem.CenterPoint.CustomerPoint.X;
            Boolean YF = BKItem.CenterPoint.CustomerPoint.Y == NoBKItem.CenterPoint.CustomerPoint.Y;
            double BKValue = Convert.ToDouble(BKItem.BK);
            double DV = 0;
            double BV = 0;
            if (NoBKItem.BushSize != 0)
                BV = NoBKItem.BushSize;
            if (NoBKItem.Dim != 0)
                DV = NoBKItem.Dim;
            Boolean VF1 = BKValue == BV;
            Boolean VF2 = BKValue == DV;
            return XF && YF && (VF1 || VF2);
        }

        //判断零件 某两个部分 数据是否一致
        public Boolean JudgeEqualItemPart(CSinglePartItem Item1, CSinglePartItem Item2)
        {
            Boolean TypeFlag = Item1.ItemType == Item2.ItemType;
            Boolean CPFlag = Item1.TVCPX == Item2.TVCPX;
            Boolean LSPFlag = Item1.LLine.StartPoint == Item2.LLine.StartPoint;
            Boolean LEPFlag = Item1.LLine.EndPoint == Item2.LLine.EndPoint;
            Boolean RSPFlag = Item1.RLine.StartPoint == Item2.RLine.StartPoint;
            Boolean REPFlag = Item1.RLine.EndPoint == Item2.RLine.EndPoint;
            return TypeFlag & CPFlag & LSPFlag & LEPFlag && RSPFlag && REPFlag;
        }

        public Boolean JudgeSameItemPart(CSinglePartItem Item1, CSinglePartItem Item2)
        {
            Boolean TypeFlag = Item1.ItemType == Item2.ItemType;
            Boolean CPFlag = Item1.AVSplitCX == Item2.AVSplitCX;
            Boolean LLXFlag = Item1.LLine.StartPoint == Item2.LLine.StartPoint;
            Boolean RLXFlag = Item1.RLine.StartPoint == Item2.RLine.StartPoint;
            return TypeFlag & CPFlag & LLXFlag & RLXFlag;
        }

        //判断零件 导套 部位是否重复
        public Boolean JudgeRepeatBushTDPart(CSinglePartItem Item1, CSinglePartItem Item2)
        {
            Boolean F1 = Math.Round(Item1.LLine.StartPoint.CustomerPoint.Y, 1) == Math.Round(Item2.LLine.StartPoint.CustomerPoint.Y, 1);
            Boolean F2 = Math.Round(Item1.LLine.EndPoint.CustomerPoint.Y, 1) == Math.Round(Item2.LLine.EndPoint.CustomerPoint.Y, 1);
            Boolean F3 = Math.Round(Item1.RLine.StartPoint.CustomerPoint.Y, 1) == Math.Round(Item2.RLine.StartPoint.CustomerPoint.Y, 1);
            Boolean F4 = Math.Round(Item1.RLine.EndPoint.CustomerPoint.Y, 1) == Math.Round(Item2.RLine.EndPoint.CustomerPoint.Y, 1);
            return F1 && F2 && F3 && F4;
        }

        //判断 套托位信息是否一致
        public Boolean JudgeSameBushTDPartInfo(SingleBushTDPartItem PartA, SingleBushTDPartItem PartB)
        {
            Boolean F1 = PartA.BushTDBoard.BoardUID == PartB.BushTDBoard.BoardUID;
            Boolean F2 = PartA.H == PartB.H;
            Boolean F3 = PartA.BushTDPosType == PartB.BushTDPosType;
            return F1 && F2 && F3;
        }

        //合并导套托位信息
        public List<PartBushTDArgItem> MergePartBushTDInfo(List<SingleBushTDPartItem> PartList)
        {
            List<PartBushTDArgItem> ResList = new List<PartBushTDArgItem>();
            var GData = PartList.GroupBy(item => item.BushTDBoard.BoardUID).ToList();
            List<List<SingleBushTDPartItem>> TargetList = GData.Select(g => g.ToList()).ToList();
            for (int i = 0; i < TargetList.Count; i++)
            {
                List<SingleBushTDPartItem> TargetItem = TargetList[i];
                PartBushTDArgItem Item = new PartBushTDArgItem();
                if (TargetItem.Count > 0)
                {
                    if (TargetItem.Count == 1)
                    {
                        Item.BushTDBoard = TargetItem[0].BushTDBoard;
                        Item.BushTH = TargetItem[0].H;
                        Item.BushHoleH = TargetItem[0].H;
                        Item.BushTDBoard = TargetItem[0].BushTDBoard;
                        Item.BushTDPosType = TargetItem[0].BushTDPosType;
                        Item.XLength = TargetItem[0].XLength;
                    }
                    else
                    {
                        Item.BushTDBoard = TargetItem[0].BushTDBoard;
                        Item.BushTH = TargetItem.Min(item => item.H);
                        Item.BushHoleH = TargetItem.Max(item => item.H);
                        Item.BushTDBoard = TargetItem[0].BushTDBoard;
                        Item.BushTDPosType = TargetItem[0].BushTDPosType;
                        Item.XLength = TargetItem[0].XLength;
                    }
                }
                ResList.Add(Item);
            }
            return ResList;
        }

        //判断拉杆的界线
        public Boolean JudgeEGPBLine(double targetX)
        {
            if (FangtieShareData.HasLRF)
            {
                if (FangtieShareData.FRXInfo.SplitX == FangtieShareData.SPAnotherFX)
                    return targetX > FangtieShareData.SPAnotherFX;
                if (FangtieShareData.FLXInfo.SplitX == FangtieShareData.SPAnotherFX)
                    return targetX < FangtieShareData.SPAnotherFX;
            }
            else
            {
                if (FangtieShareData.NOFRXInfo.SplitX == FangtieShareData.SPAnotherFX)
                    return targetX > FangtieShareData.SPAnotherFX;
                if (FangtieShareData.NOFLXInfo.SplitX == FangtieShareData.SPAnotherFX)
                    return targetX < FangtieShareData.SPAnotherFX;
            }
            return false;
        }

        //为螺丝设置与左R右L方铁的位置关系
        public static void SetScrewHoleWithFPos(List<ScrewHole> ScrewHoleList)
        {
            double? refFLX = null;
            double? refFRX = null;
            if (FangtieShareData.FLXInfo != null && FangtieShareData.FRXInfo != null)
            {
                refFLX = FangtieShareData.FLXInfo.SplitX;
                refFRX = FangtieShareData.FRXInfo.SplitX;
            }
            if (FangtieShareData.NOFLXInfo.F && FangtieShareData.NOFRXInfo.F)
            {
                refFLX = FangtieShareData.NOFLXInfo.SplitX;
                refFRX = FangtieShareData.NOFRXInfo.SplitX;
            }
            if (refFLX != null && refFRX != null)
            {
                double FLXInfo = (double)refFLX;
                double FRXInfo = (double)refFRX;
                for (int i = 0; i < ScrewHoleList.Count; i++)
                {
                    if (ScrewHoleList[i].CenterPoint.TransSplitPoint.X < FLXInfo)
                        ScrewHoleList[i].fPosType = FPosType.L;
                    if (ScrewHoleList[i].CenterPoint.TransSplitPoint.X > FRXInfo)
                        ScrewHoleList[i].fPosType = FPosType.R;
                }
            }
        }

        //钢材文字内容匹配
        public static string CompareSteel(string targetStr)
        {
            string Res = null;
            //全匹配
            List<StandardSteel> tryAllContainList = ParamsConfigData.StandardSteelList.FindAll(item => item.ItemDesc.Contains(targetStr)).ToList();
            if (tryAllContainList.Count > 0)
            {
                int resIndex = tryAllContainList.FindIndex(item => item.Equals(targetStr));
                if (resIndex != -1)
                    return tryAllContainList[resIndex].ItemDesc;
            }
            //KEY匹配某个字节后全部的文本 VALUE匹配符合起始字节的数据库文本
            Dictionary<string, List<string>> dict = new Dictionary<string, List<string>>();
            //拆分成单个进行匹配
            List<char> charList = targetStr.Select(item => item).ToList();
            if (charList.Count > 0)
            {
                for (int i = 0; i < charList.Count; i++)
                {
                    List<string> itemDescList = ParamsConfigData.StandardSteelList.Select(item => item.ItemDesc).ToList();
                    List<string> conformList = itemDescList.FindAll(item => item.Equals(charList[i])).ToList();
                    if (conformList.Count > 0)
                    {
                        string keySente = null;
                        StringBuilder sb = new StringBuilder();
                        for (int j = i; j < charList.Count; j++)
                            sb.Append(charList[j]);
                        if (sb.Length > 0)
                            keySente = sb.ToString();
                        if (keySente != null)
                            dict.Add(keySente, conformList);
                    }
                }
                if (dict.Keys.Count > 0)
                {
                    List<string> cfList = new List<string>();
                    List<string> keyList = dict.Keys.ToList();
                    for (int i = 0; i < keyList.Count; i++)
                    {
                        List<string> itemList = dict[keyList[i]];
                        List<string> comformItemList = itemList.FindAll(item => keyList[i].Contains(item));
                        if (comformItemList.Count > 0)
                            cfList.AddRange(comformItemList);
                    }
                    if (cfList.Count > 0)
                        Res = cfList.Max(item => item);
                }
            }
            return Res;
        }

        public List<ScrewHole> ReDupAndPerEGPHole(List<ScrewHole> EGPTargetList)
        {
            //去重
            List<ScrewHole> EGPTempList = new List<ScrewHole>();
            if (EGPTargetList.Count > 0)
            {
                EGPTempList.Add(EGPTargetList[0]);
                if (EGPTargetList.Count > 1)
                {
                    for (int i = 1; i < EGPTargetList.Count; i++)
                    {
                        int targetIndex = EGPTempList.FindIndex(item => EqualCenterPointDim(item, EGPTargetList[i]));
                        if (targetIndex != -1)
                        {
                            ScrewHole temp = EGPTargetList[i];
                            if (temp.TD != 0.0)
                                EGPTargetList[targetIndex].TD = temp.TD;
                            if (temp.BushSize != 0.0)
                                EGPTempList[targetIndex].BushSize = temp.BushSize;
                        }
                        else
                            EGPTempList.Add(EGPTargetList[i]);
                    }
                }
                //补充信息
                for (int i = 0; i < EGPTempList.Count; i++)
                {

                    StandardEGP ScrewItem = ParamsConfigData.StandardEGPList.Find(item => item.Dimension == EGPTempList[i].Dim);
                    if(ScrewItem != null)
                    {
                        if (EGPTempList[i].TD == 0)
                            EGPTempList[i].TD = ScrewItem.TD;
                        if (EGPTempList[i].BushSize == 0)
                            EGPTempList[i].BushSize = ScrewItem.BushSize;
                        if (EGPTempList[i].BushTD == 0)
                            EGPTempList[i].BushTD = ScrewItem.BushTD;
                    }
                }
            }
            return EGPTempList;
        }

        //转换
        public MixHoleGorupInfo TranssToTagHoleDataLogic(List<ConSpeCircle> argList)
        {
            MixHoleGorupInfo Res = new MixHoleGorupInfo();
            if (argList.Count > 0)
            {
                Res.HasF = true;
                List<MixedCAD_Point> cusHTempList = new List<MixedCAD_Point>();
                for (int i = 0; i < argList.Count; i++)
                {
                    MixedCAD_Point Item = new MixedCAD_Point();
                    //Item.CustomerPoint.X = argList[i].CenterPointInfo.CustomerPoint.X;
                    //Item.CustomerPoint.Y = argList[i].CenterPointInfo.CustomerPoint.Y;
                    //Item.TransSplitPoint.X = argList[i].CenterPointInfo.TransSplitPoint.X;
                    //Item.TransSplitPoint.Y = argList[i].CenterPointInfo.TransSplitPoint.Y;
                    Item.CustomerPoint.X = argList[i].CustomerConHPoint.X;
                    Item.CustomerPoint.Y = argList[i].CustomerConHPoint.Y;
                    cusHTempList.Add(Item);
                }
                Res.CustomerHolePList = cusHTempList;
            }
            else
                Res.HasF = false;
            return Res;
        }

        //判断小螺丝 (底板螺丝) 内径 直径
        public Boolean JudgeEpScrewInAndDim(double InDim, double Dim)
        {
            List<int> DimList = StandardShareScopeItemParam.SmallSScrewDimList;
            if (DimList.Count > 0)
            {
                int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                if (ScrewItem != null)
                {
                    double refInDim = Convert.ToDouble(ScrewItem.BaseDimension);
                    double compareInDim = Math.Round(InDim, 2);
                    return refInDim - 0.2 <= compareInDim && compareInDim <= refInDim + 0.2;
                }
            }
            return false;
        }

        //判断小螺丝 (底板螺丝) 直径 外径
        public Boolean JudgeEpScrewOutAndDim(double Dim, double OutDim)
        {
            List<int> DimList = StandardShareScopeItemParam.SmallSScrewDimList;
            if (DimList != null)
            {
                if (DimList.Count > 0)
                {
                    int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                    StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                    if (ScrewItem != null)
                    {
                        double RoundOutDim = Math.Round(OutDim, 0);
                        double TD = Convert.ToDouble(ScrewItem.TD);
                        return (TD - 2 <= RoundOutDim && RoundOutDim <= TD + 2);
                    }
                }
            }
            return false;
        }

        //识别针板螺丝 (面板螺丝 方铁螺丝) 内径 直径
        public Boolean JudgeFallerScrewInAndDim(double InDim, double Dim)
        {
            List<int> DimList = StandardShareScopeItemParam.FallerSScrewDimList;
            if (DimList != null)
            {
                if (DimList.Count > 0)
                {
                    int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                    StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                    if (ScrewItem != null)
                    {
                        double refInDim = Convert.ToDouble(ScrewItem.BaseDimension);
                        double compareInDim = Math.Round(InDim, 2);
                        return refInDim - 0.2 <= compareInDim && compareInDim <= refInDim + 0.2;
                    }
                }
            }
            return false;
        }

        //识别针板螺丝 (面板螺丝 方铁螺丝) 直径 外径
        public Boolean JudgeFallerScrewOutAndDim(double Dim, double OutDim)
        {
            List<int> DimList = StandardShareScopeItemParam.FallerSScrewDimList;
            if (DimList != null)
            {
                if (DimList.Count > 0)
                {
                    int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                    StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                    if (ScrewItem != null)
                    {
                        double RoundOutDim = Math.Round(OutDim, 0);
                        double TD = Convert.ToDouble(ScrewItem.TD);
                        return (TD - 2 <= RoundOutDim && RoundOutDim <= TD + 2);
                    }
                }
            }
            return false;
        }

        //识别大螺丝 (面板螺丝 方铁螺丝) 内径 直径
        public Boolean JudgeBigScrewInAndDim(double InDim, double Dim)
        {
            List<int> DimList = StandardShareScopeItemParam.BigSScrewDimList;
            if (DimList != null)
            {
                if (DimList.Count > 0)
                {
                    int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                    StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                    if (ScrewItem != null)
                    {
                        double refInDim = Convert.ToDouble(ScrewItem.BaseDimension);
                        double compareInDim = Math.Round(InDim, 2);
                        return refInDim - 0.2 <= compareInDim && compareInDim <= refInDim + 0.2;
                    }
                }
            }
            return false;
        }

        //识别大螺丝 (面板螺丝 方铁螺丝) 直径 TD
        public Boolean JudgeBigScrewOutAndDim(double Dim, double OutDim)
        {
            List<int> DimList = StandardShareScopeItemParam.BigSScrewDimList;
            if (DimList.Count > 0)
            {
                int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                StandardScrew ScrewItem = ParamsConfigData.StandardScrewList.Find(item => item.Dimension == CDim);
                if (ScrewItem != null)
                {
                    double RoundOutDim = Math.Round(OutDim, 0);
                    double TD = Convert.ToDouble(ScrewItem.TD);
                    return (TD - 2 <= RoundOutDim && RoundOutDim <= TD + 2);
                }
            }
            return false;
        }

        //判断 回针 直径
        public Boolean JudgeRPDim(double Dim, List<int> DimList)
        {
            if (DimList.Count > 0)
            {
                int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                Boolean F = ParamsConfigData.StandardRPList.FindIndex(item => item.Dimension == CDim) != -1;
                return F;
            }
            return false;
        }

        //判断 回针 直径 外圈圆
        public Boolean JudgeRPDimAndOutDim(double Dim, double OutDim, List<int> DimList)
        {
            if (DimList.Count > 0)
            {
                int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                StandardRP ScrewItem = ParamsConfigData.StandardRPList.Find(item => item.Dimension == CDim);
                if (ScrewItem != null)
                {
                    double RoundOutDim = Math.Round(OutDim, 0);
                    double TD = Convert.ToDouble(ScrewItem.TD);
                    return (TD - 2 <= RoundOutDim && RoundOutDim <= TD + 2);
                }
            }
            return false;
        }

        /**
        导柱平面图，3种组合：① +②（下模图），①+③（上模或下模图） ，①+③+④ （上模图）(暂不考虑)
        拉杆平面图，3种组合：⑤ （下模图，要结合组装图确定零件直径），①+③（上模图） ，①+④ （上模图）
        ① Dimension （公差±0.02）②导柱/拉杆托位（公差+1,-0）③ 导套外径公差±2）④ 导套托位（公差+1,-0）⑤ 拉杆避空孔（公差±5）
         */
        //导柱 直径 托位 ① +②
        public static Boolean JudgeGPDimTD(double Dim, double TD, List<int> DimList)
        {
            TD = Math.Round(TD, 0);
            if (DimList != null)
            {
                if (DimList.Count > 0)
                {
                    int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                    StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.Dimension == CDim);

                    if (ScrewItem != null)
                        return (Convert.ToDouble(ScrewItem.TD) - 1 <= TD && TD <= Convert.ToDouble(ScrewItem.TD) + 1);
                }
            }
            return false;
        }

        //导柱 直径 导套外径 ①+③
        public static Boolean JudgeGPDimBushSize(double Dim, double ParamBushSize, List<int> DimList)
        {
            if (DimList != null)
            {
                if (DimList.Count > 0)
                {
                    int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                    StandardGPSP ScrewItem = ParamsConfigData.StandardGPList.Find(item => item.Dimension == CDim);

                    if (ScrewItem != null)
                    {
                        ParamBushSize = Math.Round(ParamBushSize, 0);
                        double BushSize = Convert.ToDouble(ScrewItem.BushSize);
                        return (BushSize - 2 <= ParamBushSize && ParamBushSize <= BushSize + 2);
                    }
                }
            }
            return false;
        }

        //判断 拉杆 避空孔 ⑤
        public static Boolean JudgeSPBK(double BK)
        {
            BK = Math.Round(BK, 0);
            List<int> BKList = new List<int>();
            List<StandardGPSP> StandardList = ParamsConfigData.StandardSPList;
            List<int> DimList = StandardShareScopeItemParam.SPScrewDimList;
            if (DimList.Count > 0)
            {
                for (int i = 0; i < DimList.Count; i++)
                {
                    StandardGPSP GPItem = StandardList.Find(item => item.Dimension == DimList[i]);
                    if (GPItem != null)
                        BKList.Add(GPItem.BK_2);
                }
            }
            int index = BKList.FindIndex(item => item - 5 <= BK && BK <= item + 2);
            if (index != -1)
                return true;
            return false;
        }

        //判断 拉杆 直径 导套外径 ①+③
        public static Boolean JudgeSPDimBushSize(double Dim, double BashSize)
        {
            BashSize = Math.Round(BashSize, 0);
            List<int> DimList = StandardShareScopeItemParam.SPScrewDimList;
            if (DimList.Count > 0)
            {
                int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                StandardGPSP ScrewItem = ParamsConfigData.StandardSPList.Find(item => item.Dimension == CDim);

                if (ScrewItem != null)
                    return (Convert.ToDouble(ScrewItem.BushSize) - 2 <= BashSize
                        && BashSize <= Convert.ToDouble(ScrewItem.BushSize) + 2);
            }
            return false;
        }

        //拉杆 直径 导套托位 ①+④
        public static Boolean JudgeSPDimBushTD(double Dim, double BushTD)
        {
            BushTD = Math.Round(BushTD, 0);
            List<int> DimList = StandardShareScopeItemParam.SPScrewDimList;
            if (DimList != null)
            {
                if (DimList.Count > 0)
                {
                    int CDim = DimList.Find(item => item - 0.02 <= Dim && Dim <= item + 0.02);
                    StandardGPSP ScrewItem = ParamsConfigData.StandardSPList.Find(item => item.Dimension == CDim);

                    if (ScrewItem != null)
                        return (Convert.ToDouble(ScrewItem.BushTD) - 1 <= BushTD && BushTD <= Convert.ToDouble(ScrewItem.BushSize) + 1);
                }
            }
            return false;
        }

        //判断两线段斜率相等
        public Boolean JudgeTwoLineSlopeEqual(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            double epsilon = 0.01; // 允许的误差范围
            double deltaX1 = Math.Abs(line1.StartPoint.CustomerPoint.X - line1.EndPoint.CustomerPoint.X);
            double deltaY1 = Math.Abs(line1.StartPoint.CustomerPoint.Y - line1.EndPoint.CustomerPoint.Y);
            double deltaX2 = Math.Abs(line2.StartPoint.CustomerPoint.X - line2.EndPoint.CustomerPoint.X);
            double deltaY2 = Math.Abs(line2.StartPoint.CustomerPoint.Y - line2.EndPoint.CustomerPoint.Y);
            //斜率
            double Slope1 = deltaY1 / deltaX1;
            double Slope2 = deltaY2 / deltaX2;

            // 判断斜率是否相等
            bool isSlopeEqual = Math.Abs(Slope1 - Slope2) < epsilon;
            // 形成的角相对结构是否符合尖的定义
            bool SameSXF = Math.Round(line1.StartPoint.CustomerPoint.X, 1) != Math.Round(line2.EndPoint.CustomerPoint.X, 1);
            return isSlopeEqual && SameSXF;
        }

        //判断两线几乎相等且几乎相连
        public double JudgeTwoLineConnLEqual(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            if (Math.Round(line1.Length, 0) == Math.Round(line2.Length, 0))
            {
                if (Math.Round(line1.StartPoint.TransSplitPoint.X, 0) == Math.Round(line2.StartPoint.TransSplitPoint.X, 0)
                    && Math.Round(line1.StartPoint.TransSplitPoint.Y, 0) == Math.Round(line2.StartPoint.TransSplitPoint.Y, 0))
                    return line1.StartPoint.TransSplitPoint.X;

                if (Math.Round(line1.StartPoint.TransSplitPoint.X, 0) == Math.Round(line2.EndPoint.TransSplitPoint.X, 0)
                    && Math.Round(line1.StartPoint.TransSplitPoint.Y, 0) == Math.Round(line2.EndPoint.TransSplitPoint.Y, 0))
                    return line1.StartPoint.TransSplitPoint.X;

                if (Math.Round(line1.EndPoint.TransSplitPoint.X, 0) == Math.Round(line2.StartPoint.TransSplitPoint.X, 0)
                    && Math.Round(line1.EndPoint.TransSplitPoint.Y, 0) == Math.Round(line2.StartPoint.TransSplitPoint.Y, 0))
                    return line1.EndPoint.TransSplitPoint.X;

                if (Math.Round(line1.EndPoint.TransSplitPoint.X, 0) == Math.Round(line2.EndPoint.TransSplitPoint.X, 0)
                    && Math.Round(line1.EndPoint.TransSplitPoint.Y, 0) == Math.Round(line2.EndPoint.TransSplitPoint.Y, 0))
                    return line1.EndPoint.TransSplitPoint.X;
            }
            return -1;
        }

        //判断横线起点or终点是否与圆弧相交
        public Boolean JudgeHorizontalLineArcConn(MixedCAD_Line line, MixedCAD_Arc arc)
        {
            Boolean FlagSS = Math.Round(line.StartPoint.CustomerPoint.X, 1) == Math.Round(arc.StartPoint.CustomerPoint.X, 1)
                && Math.Round(line.StartPoint.CustomerPoint.Y, 1) == Math.Round(arc.StartPoint.CustomerPoint.Y, 1);
            Boolean FlagSE = Math.Round(line.StartPoint.CustomerPoint.X, 1) == Math.Round(arc.EndPoint.CustomerPoint.X, 1)
                && Math.Round(line.StartPoint.CustomerPoint.Y, 1) == Math.Round(arc.EndPoint.CustomerPoint.Y, 1);
            Boolean FlagES = Math.Round(line.EndPoint.CustomerPoint.X, 1) == Math.Round(arc.StartPoint.CustomerPoint.X, 1)
                && Math.Round(line.EndPoint.CustomerPoint.Y, 1) == Math.Round(arc.StartPoint.CustomerPoint.Y, 1);
            Boolean FlagEE = Math.Round(line.EndPoint.CustomerPoint.X, 1) == Math.Round(arc.EndPoint.CustomerPoint.X, 1)
                && Math.Round(line.EndPoint.CustomerPoint.Y, 1) == Math.Round(arc.EndPoint.CustomerPoint.Y, 1);
            return FlagSS || FlagSE || FlagES || FlagEE;
        }

        //判断竖线最低点Y是否与圆弧相交
        public Boolean JudgeVerticalLineEndPointArcConn(MixedCAD_Line line, MixedCAD_Arc arc)
        {
            double lineEX = Math.Round(line.EndPoint.CustomerPoint.X, 1);
            double arcSX = Math.Round(arc.StartPoint.CustomerPoint.X, 1);
            Boolean F1 = lineEX - 1 <= arcSX && arcSX <= lineEX + 1;
            double lineEY = Math.Round(line.EndPoint.CustomerPoint.Y, 1);
            double arcSY = Math.Round(arc.StartPoint.CustomerPoint.Y, 1);
            Boolean F2 = lineEY - 1 <= arcSY && arcSY <= lineEY + 1;
            return F1 && F2;
        }

        //判断圆弧的中心在直线上
        public Boolean JudgeArcCenterInLine(MixedCAD_Line line, MixedCAD_Arc arc)
        {
            double SX = Math.Round(line.StartPoint.CustomerPoint.X, 1);
            double EX = Math.Round(line.EndPoint.CustomerPoint.X, 1);
            double ARCX = Math.Round(arc.CenterPoint.CustomerPoint.X, 1);
            Boolean F1 = SX <= ARCX && ARCX <= EX;
            Boolean F2 = Math.Round(line.StartPoint.CustomerPoint.Y, 1) == Math.Round(arc.CenterPoint.CustomerPoint.Y, 1);
            return F1 && F2;
        }

        //无方铁的情况下 需要补充的标准宽度
        public double FangtieSPWidth(double PlateWidth)
        {
            double fangtieWidth = 0.0;
            List<double> RefParamsList = new List<double>() { 150, 180, 200, 230, 250, 270, 300, 350, 400, 450, 500, 600, 700, 750, 800 };
            double RefWidth = PlateWidth;
            if (RefParamsList.Contains(RefWidth))
            {
                switch (RefWidth)
                {
                    case 150:
                        {
                            fangtieWidth = 28;
                            break;
                        }
                    case 180:
                        {
                            fangtieWidth = 33;
                            break;
                        }
                    case 200:
                        {
                            fangtieWidth = 38;
                            break;
                        }
                    case 230:
                        {
                            fangtieWidth = 43;
                            break;
                        }
                    case 250:
                        {
                            fangtieWidth = 48;
                            break;
                        }
                    case 270:
                        {
                            fangtieWidth = 53;
                            break;
                        }
                    case 300:
                        {
                            fangtieWidth = 58;
                            break;
                        }
                    case 350:
                        {
                            fangtieWidth = 63;
                            break;
                        }
                    case 400:
                        {
                            fangtieWidth = 68;
                            break;
                        }
                    case 450:
                        {
                            fangtieWidth = 78;
                            break;
                        }
                    case 500:
                        {
                            fangtieWidth = 88;
                            break;
                        }
                }
                if (RefWidth == 500 || RefWidth == 600)
                    fangtieWidth = 100;

                if (RefWidth == 700 || RefWidth == 750 || RefWidth == 800)
                    fangtieWidth = 120;
            }
            else
            {
                //向上取标准
                int LIndex = RefParamsList.FindIndex(item => item > RefWidth);
                if (LIndex != -1)
                {
                    RefWidth = RefParamsList[LIndex];
                    return FangtieSPWidth(RefWidth);
                }
                //真太大了 直接返回最大的
                else
                    fangtieWidth = 120;
            }
            return fangtieWidth;
        }


        //圆弧的两个端点近似落在某两条直线上(判断非标准画法精框避空圆弧)
        public Boolean JudgeNoStandArcBK(MixedCAD_Arc targetArc, double X, double Y)
        {
            double SX = targetArc.StartPoint.CustomerPoint.X;
            double EY = targetArc.EndPoint.CustomerPoint.Y;
            Boolean F1 = SX - 0.5 <= X && X <= SX + 0.5;
            Boolean F2 = EY - 0.5 <= Y && Y <= EY + 0.5;
            double EX = targetArc.EndPoint.CustomerPoint.X;
            double SY = targetArc.StartPoint.CustomerPoint.Y;
            Boolean F3 = EX - 0.5 <= X && X <= EX + 0.5;
            Boolean F4 = SY - 0.5 <= Y && Y <= SY + 0.5;
            return (F1 && F2) || (F3 && F4);
        }

        //public List<ScrewHole> TransToDBRefSHList(CAD_Point refPoint, List<ScrewHole> targetList)
        //{
        //    List<ScrewHole> ResList = new List<ScrewHole>();
        //    if(targetList.Count > 0)
        //    {
        //        ResList = (List<ScrewHole>)ConvertUtils.DeepCopyObject(targetList);
        //        for(int i = 0;i < ResList.Count; i++)
        //        {
        //            ResList[i].CenterPoint.X = Convert.ToInt32(Math.Round(ResList[i].CenterPoint.X - refPoint.X, 2));
        //            ResList[i].CenterPoint.Y = Convert.ToInt32(Math.Round(ResList[i].CenterPoint.Y - refPoint.Y, 2));
        //        }
        //    }
        //    return ResList;
        //}

        public List<IHPSInfo> GetdbAllItemMatchNameList()
        {
            List<IHPSInfo> ResList = new List<IHPSInfo>();
            Dictionary<string, IHPSInfo> Dic = new Dictionary<string, IHPSInfo>();
            string CategoryStr = CADCommonForm.CategoryStr;
            List<StandardBoardItemNormSub> BINormSubList = ParamsConfigData.StandardBoardItemNormSubList.FindAll(
                item => item.category.Equals(CategoryStr)).ToList();
            if(BINormSubList.Count > 0)
            {
                for (int i = 0; i< BINormSubList.Count; i++)
                {
                    string keyCode = BINormSubList[i].partCode;
                    string boardV = null;
                    string[] bvArray = BINormSubList[i].aboutBoard.Split('_');
                    if (bvArray.Count() >= 2)
                        boardV = bvArray[1];
                    else
                        boardV = bvArray[0];
                    Boolean keyF = Dic.ContainsKey(keyCode);
                    if (keyF)
                        Dic[keyCode].GoByBoardList.Add(boardV);
                    else
                    {
                        IHPSInfo tempItem = new IHPSInfo();
                        tempItem.ItemCode = keyCode;
                        tempItem.GoByBoardList.Add(boardV);
                        Dic.Add(keyCode, tempItem);
                    }
                }
            }

            //Process About Bush(Merge Bush Board To GP or SP)
            if (Dic.Keys.ToList().Count > 0)
            {
                List<IHPSInfo> tempList = Dic.Values.ToList();
                List<IHPSInfo> bushList = tempList.FindAll(item => item.ItemCode.Contains("Bush"));
                List<IHPSInfo> noBushList = tempList.FindAll(item => !item.ItemCode.Contains("Bush"));
                if (bushList.Count > 0 && noBushList.Count > 0)
                {
                    for (int i = 0; i < bushList.Count; i++)
                    {
                        List<string> bushBList = bushList[i].GoByBoardList;
                        int nobushGPIndex = noBushList.FindIndex(item => item.ItemCode.Equals("GuidePin"));
                        if (nobushGPIndex != -1)
                        {
                            List<string> bcList = noBushList[nobushGPIndex].GoByBoardList;
                            bcList.AddRange(bushBList);
                            bcList = bcList.Distinct().ToList();
                        }
                        int nobushSPIndex = noBushList.FindIndex(item => item.ItemCode.Equals("SupportPin"));
                        if (nobushSPIndex != -1)
                        {
                            List<string> bcList = noBushList[nobushSPIndex].GoByBoardList;
                            bcList.AddRange(bushBList);
                            bcList = bcList.Distinct().ToList();
                        }
                    }
                }
                ResList = noBushList;
            }

            return ResList;
        }

        public  Boolean JudgeDupRItem(SingleItem Item1, SingleItem Item2)
        {
            Boolean CF = Item1.MatchScrewHole.CenterPoint == Item2.MatchScrewHole.CenterPoint;
            Boolean DimF = Item1.Dim == Item2.Dim;
            Boolean HF = Item1.RealScrewH == Item2.RealScrewH;
            Boolean F = CF && DimF && HF;
            return F;
        }

        public Boolean CompareTVAndDBHole(List<ScrewHole> tvHoleList, List<StandardHoleData> DBHoleList)
        {
            
            Boolean Res = false;
            int matchNum = 0;
            int tvNum = tvHoleList.Count;
            int dbNum = DBHoleList.Count;
            if(tvNum == dbNum && tvNum == 0)
                return Res;

            if (tvNum < dbNum)
                return Res;
            else
            {
               double tvDim = tvHoleList.First().Dim;
               double dbDim = DBHoleList.First().ItemDim;
                if (tvDim != dbDim)
                    return Res;
               List<CAD_Point> tvList = tvHoleList.Select(item =>
               new CAD_Point(Math.Round(item.CenterPoint.TransSplitPoint.X,2),
               Math.Round(item.CenterPoint.TransSplitPoint.Y,2), 0)).ToList();
               List<CAD_Point> dbList = DBHoleList.Select(item => new CAD_Point(item.ItemX,item.ItemY, 0)).ToList();
                for (int i = 0; i < tvNum; i++)
                {
                    Boolean F = dbList.FindIndex(item => item == tvList[i]) != -1;
                    if (F)
                        matchNum++;
                }
                if(matchNum == dbNum)
                    Res = true;
            }
            return Res;
        }

        //判断套是否为短套
        public Boolean JudgeShortBush(SingleItem bushItem)
        {
            Boolean Res = false;
            Boolean F = bushItem.ItemCode.Contains("BBush");
            if (F)
            {
                double BushRealH = bushItem.RealH;
                double allBushBoardThick = bushItem.BushTDBoard.PlateThick;
                if (BushRealH < allBushBoardThick)
                    Res = true;
            }
            return Res;
        }

        //RP 加工数据 
        public void RPTransToProcessData(SingleItem RPItem)
        {
            StandardRP standParams = ComputedAboutRPParams((int)RPItem.Dim);
            RPItem.InputTD = standParams.TD + 1;
            RPItem.InputTH = standParams.TH;
        }

        //RP 根据客图 直径 结合标准 推算沉头TD TH
        public StandardRP ComputedAboutRPParams(int dim)
        {
            StandardRP Res = new StandardRP();
            List<StandardRP> rpList = ParamsConfigData.StandardRPList;
            int targetIndex = rpList.FindIndex(item => item.Dimension == dim);
            if (targetIndex != -1)
                Res = rpList[targetIndex];
            else
            {
                int PerWIndex = rpList.FindLastIndex(item => item.Dimension < dim);
                int NextWIndex = rpList.FindIndex(item => item.Dimension > dim);
                Boolean F1 = PerWIndex != -1;
                Boolean F2 = NextWIndex != -1;
                if (F1 && F2)
                {
                    int PerW = rpList[PerWIndex].Dimension;
                    int NextW = rpList[NextWIndex].Dimension;
                    int DiffPerW = Math.Abs(PerW - dim);
                    int DiffNextW = Math.Abs(NextW - dim);
                    if (DiffPerW == DiffNextW)
                        Res = rpList[NextWIndex];
                    else
                        Res = DiffPerW < DiffNextW ? rpList[PerWIndex] : rpList[NextWIndex];
                }
                else
                {
                    if (F1)
                        Res = rpList[PerWIndex];
                    if (F2)
                        Res = rpList[NextWIndex];
                }
            }
            return Res;
        }

        //SP GP 根据客图 直径 结合标准 推算沉头TD TH
        public StandardGPSP ComputedSAboutSPGPParams(string ItemCodeName, int dim)
        {
            StandardGPSP Res = new StandardGPSP();
            List<StandardGPSP> gpList = ParamsConfigData.StandardGPList;
            List<StandardGPSP> spList = ParamsConfigData.StandardSPList;

            if (ItemCodeName.Equals("GP"))
            {
                int targetIndex = gpList.FindIndex(item => item.Dimension == dim);
                if (targetIndex != -1)
                    Res = gpList[targetIndex];
                else
                {
                    int PerWIndex = gpList.FindLastIndex(item => item.Dimension < dim);
                    int NextWIndex = gpList.FindIndex(item => item.Dimension > dim);
                    Boolean F1 = PerWIndex != -1;
                    Boolean F2 = NextWIndex != -1;
                    if (F1 && F2)
                    {
                        int PerW = gpList[PerWIndex].Dimension;
                        int NextW = gpList[NextWIndex].Dimension;
                        int DiffPerW = Math.Abs(PerW - dim);
                        int DiffNextW = Math.Abs(NextW - dim);
                        if (DiffPerW == DiffNextW)
                            Res = gpList[NextWIndex];
                        else
                            Res = DiffPerW < DiffNextW ? gpList[PerWIndex] : gpList[NextWIndex];
                    }
                    else
                    {
                        if (F1)
                            Res = gpList[PerWIndex];
                        if (F2)
                            Res = gpList[NextWIndex];
                    }
                }
            }

            if (ItemCodeName.Equals("GPBush"))
            {
                int targetIndex = gpList.FindIndex(item => item.BushSize == dim);
                if(targetIndex != -1)
                    Res = gpList[targetIndex];
                else
                {
                    int PerWIndex = gpList.FindLastIndex(item => item.BushSize < dim);
                    int NextWIndex = gpList.FindIndex(item => item.BushSize > dim);
                    Boolean F1 = PerWIndex != -1;
                    Boolean F2 = NextWIndex != -1;
                    if (F1 && F2)
                    {
                        int PerW = gpList[PerWIndex].BushSize;
                        int NextW = gpList[NextWIndex].BushSize;
                        int DiffPerW = Math.Abs(PerW - dim);
                        int DiffNextW = Math.Abs(NextW - dim);
                        if (DiffPerW == DiffNextW)
                            Res = gpList[NextWIndex];
                        else
                            Res = DiffPerW < DiffNextW ? gpList[PerWIndex] : gpList[NextWIndex];
                    }
                    else
                    {
                        if (F1)
                            Res = gpList[PerWIndex];
                        if (F2)
                            Res = gpList[NextWIndex];
                    }
                }
            }

            if (ItemCodeName.Equals("SP"))
            {
                int targetIndex = spList.FindIndex(item => item.Dimension == dim);
                if (targetIndex != -1)
                    Res = spList[targetIndex];
                else
                {
                    int PerWIndex = spList.FindLastIndex(item => item.Dimension < dim);
                    int NextWIndex = spList.FindIndex(item => item.Dimension > dim);
                    Boolean F1 = PerWIndex != -1;
                    Boolean F2 = NextWIndex != -1;
                    if (F1 && F2)
                    {
                        int PerW = spList[PerWIndex].Dimension;
                        int NextW = spList[NextWIndex].Dimension;
                        int DiffPerW = Math.Abs(PerW - dim);
                        int DiffNextW = Math.Abs(NextW - dim);
                        if (DiffPerW == DiffNextW)
                            Res = spList[NextWIndex];
                        else
                            Res = DiffPerW < DiffNextW ? spList[PerWIndex] : spList[NextWIndex];
                    }
                    else
                    {
                        if (F1)
                            Res = spList[PerWIndex];
                        if (F2)
                            Res = spList[NextWIndex];
                    }
                }
            }

            if (ItemCodeName.Equals("SPBush"))
            {
                int targetIndex = spList.FindIndex(item => item.BushSize == dim);
                if (targetIndex != -1)
                    Res = spList[targetIndex];
                else
                {
                    int PerWIndex = spList.FindLastIndex(item => item.BushSize < dim);
                    int NextWIndex = spList.FindIndex(item => item.BushSize > dim);
                    Boolean F1 = PerWIndex != -1;
                    Boolean F2 = NextWIndex != -1;
                    if (F1 && F2)
                    {
                        int PerW = spList[PerWIndex].BushSize;
                        int NextW = spList[NextWIndex].BushSize;
                        int DiffPerW = Math.Abs(PerW - dim);
                        int DiffNextW = Math.Abs(NextW - dim);
                        if (DiffPerW == DiffNextW)
                            Res = spList[NextWIndex];
                        else
                            Res = DiffPerW < DiffNextW ? spList[PerWIndex] : spList[NextWIndex];
                    }
                    else
                    {
                        if (F1)
                            Res = spList[PerWIndex];
                        if (F2)
                            Res = spList[NextWIndex];
                    }
                }
            }

            return Res;
        }

        //EGP
        public StandardEGP ComputedSAboutEGPParams(int dim)
        {
            StandardEGP Res = new StandardEGP();
            List<StandardEGP> egpList = ParamsConfigData.StandardEGPList;
            int targetIndex = egpList.FindIndex(item => item.Dimension == dim);
            if (targetIndex != -1)
                Res = egpList[targetIndex];
            else
            {
                int PerWIndex = egpList.FindLastIndex(item => item.Dimension < dim);
                int NextWIndex = egpList.FindIndex(item => item.Dimension > dim);
                Boolean F1 = PerWIndex != -1;
                Boolean F2 = NextWIndex != -1;
                if (F1 && F2)
                {
                    int PerW = egpList[PerWIndex].Dimension;
                    int NextW = egpList[NextWIndex].Dimension;
                    int DiffPerW = Math.Abs(PerW - dim);
                    int DiffNextW = Math.Abs(NextW - dim);
                    if (DiffPerW == DiffNextW)
                        Res = egpList[NextWIndex];
                    else
                        Res = DiffPerW < DiffNextW ? egpList[PerWIndex] : egpList[NextWIndex];
                }
                else
                {
                    if (F1)
                        Res = egpList[PerWIndex];
                    if (F2)
                        Res = egpList[NextWIndex];
                }
            }
            return Res;
        } 

        //根据客图螺丝Dim 结合标准 推算沉头TD TH
        public StandardScrew ComputedSScrewParams(int dim)
        {
            StandardScrew Res = new StandardScrew();

            List<StandardScrew> screwList = ParamsConfigData.StandardScrewList;
            int targetIndex = screwList.FindIndex(item => item.Dimension == dim);
            if (targetIndex != -1)
                Res = screwList[targetIndex];
            else
            {
                int PerWIndex = screwList.FindLastIndex(item => item.Dimension < dim);
                int NextWIndex = screwList.FindIndex(item => item.Dimension > dim);
                Boolean F1 = PerWIndex != -1;
                Boolean F2 = NextWIndex != -1;
                if (F1 && F2)
                {
                    int PerW = screwList[PerWIndex].Dimension;
                    int NextW = screwList[NextWIndex].Dimension;
                    int DiffPerW = Math.Abs(PerW - dim);
                    int DiffNextW = Math.Abs(NextW - dim);
                    if (DiffPerW == DiffNextW)
                        Res = screwList[NextWIndex];
                    else
                        Res = DiffPerW < DiffNextW ? screwList[PerWIndex] : screwList[NextWIndex];
                }
                else
                {
                    if (F1)
                        Res = screwList[PerWIndex];
                    if (F2)
                        Res = screwList[NextWIndex];
                }
            }
            return Res;
        }

        //螺丝 加工数据 入数转换 TD + 1单位
        public void ScrewTransToProcessData(SingleItem Item)
        {
            StandardScrew standParams = ComputedSScrewParams((int)Item.Dim);
            Item.InputTD = standParams.TD + 1;
            Item.InputTH = standParams.TH;
        }

        //导柱 拉杆 托位 加工数据 入数转换 TD + 1单位
        public void SPGPTransToProcessData(string ItemCodeName, SingleItem Item)
        {
            Boolean F1 = ItemCodeName.Contains("GP");
            Boolean F2 = ItemCodeName.Contains("SP");
            if (F1)
            {
                StandardGPSP standParams = ComputedSAboutSPGPParams("GP", (int)Item.Dim);
                Item.InputTD = standParams.TD + 1;
                Item.InputTH = standParams.TH;
            }
            if (F2)
            {
                StandardGPSP standParams = ComputedSAboutSPGPParams("SP", (int)Item.Dim);
                Item.InputTD = standParams.TD + 1;
                Item.InputTH = standParams.TH;
            }
            
        }

        //EGP 加工盲孔 
        public static double ProcessEGPBlindDepth(SingleItem EGPItem)
        {
            double egpDim = EGPItem.Dim;
            Boolean DimF1 = 12 <= egpDim && egpDim <= 20;
            if (DimF1)
                return 22;
            Boolean DimF2 = egpDim >= 25;
            if (DimF2)
                return 27;
            return 0;
        }

        //GP SP 导套 加工数据 入数转换 TD + 1单位
        public void BushTransToProcessData(string ItemCodeName,SingleItem Item)
        {
            Boolean shortF = JudgeShortBush(Item);
            Boolean F1 = ItemCodeName.Equals("GPBush");
            Boolean F2 = ItemCodeName.Equals("SPBush");
            if (!shortF)
            {
                if (F1)
                {
                    StandardGPSP standParams = ComputedSAboutSPGPParams("GPBush", Item.BushSize);
                    Item.InputBushSize = standParams.BushSize;
                    Item.InputBushTH = standParams.BushTH;
                    Item.InputBushTD = standParams.BushTD + 1;
                }
                if (F2)
                {
                    StandardGPSP standParams = ComputedSAboutSPGPParams("SPBush", Item.BushSize);
                    Item.InputBushSize = standParams.BushSize;
                    Item.InputBushTH = standParams.BushTH;
                    Item.InputBushTD = standParams.BushTD + 1;
                }
            }
            else
            {
                Item.InputBushSize = (int)Item.BushSize;
                Item.InputBushTH = (int)Item.BushTH;
                Item.InputBushTD = Item.BushTD;
            }
        }

        //标准孔距名称 转换成 数据库表 StandardScrew Item字段
        public string TranDBStrandHoleItemName(DItemNameType ItemNameType)
        {
            switch (ItemNameType)
            {
                case DItemNameType.ReturnPin:
                    return "回针";
                case DItemNameType.GuidePin:
                    return "导柱";
                case DItemNameType.SupportPin:
                    return "拉杆";
                case DItemNameType.NoNozzleMesonSupportPin:
                    return "拉杆";
                case DItemNameType.EGPPin:
                    return "中托边";
                case DItemNameType.PinBoardScrew:
                    return "针板螺丝";
                case DItemNameType.TopPanelScrew:
                    return "大螺丝";
                case DItemNameType.SpaceBlockScrew:
                    return "大螺丝";
                case DItemNameType.BottomPanelScrew:
                    return "小螺丝";
       
            }
            return null;
        }

        //设置板名
        public string SetBoardNameByCode(string Code)
        {
            switch (Code)
            {
                case "hsBoard":
                    return "隔热板";
                case "sfangtie":
                    return "上方铁";
                case "hrBoard":
                    return "热流道板";
                case "mpBoard":
                    return "垫板";
                case "aBoard":
                    return "A板";
                case "bBoard":
                    return "B板";
                case "bpBoard":
                    return "底板";
                case "cpBoard":
                    return "水口面板";
                case "epBoard":
                    return "下针板";//底针板
                case "fangtie":
                    return "方铁";
                case "fpBoard":
                    return "上针板";//面针板
                case "rspBoard":
                    return "水口推板";//面针板
                case "spBoard":
                    return "托板";
                case "stBoard":
                    return "推板";
                case "tpBoard":
                    return "面板";
                case "sepBoard":
                    return "隔板";
                case "hnpBoard":
                    return "热水口板";
                case "epfpBoard":
                    return "上针板&下针板";
            }
            return "";
        }

        //零件ERP的显示排序
        public int SetSortByItemNameType(DItemNameType ItemNameType)
        {
            //导柱 导套 回针 面板螺丝 方铁螺丝 底板螺丝 针板螺丝
            string MoldTypeStr = CADCommonForm.MoldTypeStr;
            //大水口 简化型 B套在前
            if (MoldTypeStr.Equals("SG") || MoldTypeStr.Equals("TP"))
            {
                if (ItemNameType == DItemNameType.GuidePin)
                    return 1;
                if (ItemNameType == DItemNameType.GuideBBush)
                    return 2;
                if (ItemNameType == DItemNameType.GuideABush)
                    return 3;
                if (ItemNameType == DItemNameType.SupportPin)
                    return 4;
                if (ItemNameType == DItemNameType.NoNozzleMesonSupportPin)
                    return 4;
                if (ItemNameType == DItemNameType.Meson)
                    return 5;
                if (ItemNameType == DItemNameType.MesonScrew)
                    return 6;
                if (ItemNameType == DItemNameType.SupportPinBBush)
                    return 7;
                if (ItemNameType == DItemNameType.NoNozzleMesonSupportPinBBush)
                    return 7;
                if (ItemNameType == DItemNameType.SupportPinABush)
                    return 8;
                if (ItemNameType == DItemNameType.NoNozzleMesonSupportPinABush)
                    return 8;
                if (ItemNameType == DItemNameType.ReturnPin)
                    return 9;
                if (ItemNameType == DItemNameType.ReturnPinScrew)
                    return 10;
                if (ItemNameType == DItemNameType.TopPanelScrew)
                    return 11;
                if (ItemNameType == DItemNameType.SpaceBlockScrew)
                    return 12;
                if (ItemNameType == DItemNameType.GenericScrew)
                    return 12;
                if (ItemNameType == DItemNameType.BottomPanelScrew)
                    return 13;
                if (ItemNameType == DItemNameType.PinBoardScrew)
                    return 14;
                if (ItemNameType == DItemNameType.EGPPin)
                    return 15;
                if (ItemNameType == DItemNameType.EGPBush)
                    return 16;
                return 20;
            }

            //细水口 A套在前
            if (ItemNameType == DItemNameType.GuidePin)
                return 1;
            if (ItemNameType == DItemNameType.GuideABush)
                return 2;
            if (ItemNameType == DItemNameType.GuideBBush)
                return 3;
            if (ItemNameType == DItemNameType.SupportPin)
                return 4;
            if (ItemNameType == DItemNameType.NoNozzleMesonSupportPin)
                return 4;
            if (ItemNameType == DItemNameType.Meson)
                return 5;
            if (ItemNameType == DItemNameType.MesonScrew)
                return 6;
            if (ItemNameType == DItemNameType.SupportPinABush)
                return 7;
            if (ItemNameType == DItemNameType.NoNozzleMesonSupportPinABush)
                return 7;
            if (ItemNameType == DItemNameType.SupportPinBBush)
                return 8;
            if (ItemNameType == DItemNameType.NoNozzleMesonSupportPinBBush)
                return 8;
            if (ItemNameType == DItemNameType.ReturnPin)
                return 9;
            if (ItemNameType == DItemNameType.ReturnPinScrew)
                return 10;
            if (ItemNameType == DItemNameType.TopPanelScrew)
                return 11;
            if (ItemNameType == DItemNameType.SpaceBlockScrew)
                return 12;
            if (ItemNameType == DItemNameType.BottomPanelScrew)
                return 13;
            if (ItemNameType == DItemNameType.PinBoardScrew)
                return 14;
            if (ItemNameType == DItemNameType.EGPPin)
                return 15;
            if (ItemNameType == DItemNameType.EGPBush)
                return 16;
            return 20;
        }

        //根据零件Code设置零件NameType
        public static DItemNameType SetItemNameTypeByCode(string Code)
        {
            switch (Code)
            {
                case "GuidePin":
                    return DItemNameType.GuidePin;
                case "GuideABush":
                    return DItemNameType.GuideABush;
                case "GuideBBush":
                    return DItemNameType.GuideBBush;
                case "SupportPin":
                    return DItemNameType.SupportPin;
                case "SupportPinABush":
                    return DItemNameType.SupportPinABush;
                case "SupportPinBBush":
                    return DItemNameType.SupportPinBBush;
                case "ReturnPin":
                    return DItemNameType.ReturnPin;
                case "PinBoardScrew":
                    return DItemNameType.PinBoardScrew;
                case "TopPanelScrew":
                    return DItemNameType.TopPanelScrew;
                case "BottomPanelScrew":
                    return DItemNameType.BottomPanelScrew;
                case "SpaceBlockScrew":
                    return DItemNameType.SpaceBlockScrew;

                case "ReturnPinScrew":
                    return DItemNameType.ReturnPinScrew;
                case "GenericScrew":
                    return DItemNameType.GenericScrew;
                case "Meson":
                    return DItemNameType.Meson;
                case "MesonScrew":
                    return DItemNameType.MesonScrew;
            }
            return DItemNameType.NONE;
        }

        //根据零件中文 返回零件Code
        public string SetItemCodeByItemName(string ItemName)
        {
            switch (ItemName)
            {
                case "导柱":
                    return "GuidePin";
                case "拉杆":
                    return "SupportPin";
                case "A套(导柱)":
                    return "GuideABush";
                case "B套(导柱)":
                    return "GuideBBush";
                case "A套(拉杆)":
                    return "SupportPinABush";
                case "B套(拉杆)":
                    return "SupportPinBBush";
                case "中托边":
                    return "EGPPin";
                case "中托司":
                    return "EGPBush";
                case "回针":
                    return "ReturnPin";
                case "回针螺丝":
                    return "ReturnPinScrew";
                case "针板螺丝":
                    return "PinBoardScrew";
                case "面板螺丝":
                    return "TopPanelScrew";
                case "底板螺丝":
                    return "BottomPanelScrew";
                case "方铁螺丝":
                    return "SpaceBlockScrew";
            }
            return string.Empty;
        }

        //设置零件名称
        public string SetItemNameByType(DItemNameType type)
        {
            switch (type)
            {
                case DItemNameType.GuidePin:
                    return "导柱";
                case DItemNameType.GuideABush:
                    return "A套(导柱)";
                case DItemNameType.GuideBBush:
                    return "B套(导柱)";
                case DItemNameType.SupportPin:
                    return "拉杆";
                case DItemNameType.SupportPinABush:
                    return "A套(拉杆)";
                case DItemNameType.SupportPinBBush:
                    return "B套(拉杆)";
                case DItemNameType.NoNozzleMesonSupportPin:
                    return "导柱(无介子)";
                case DItemNameType.NoNozzleMesonSupportPinABush:
                    return "A套(导柱无介子)";
                case DItemNameType.NoNozzleMesonSupportPinBBush:
                    return "B套(导柱无介子)";
                case DItemNameType.EGPPin:
                    return "中托边";
                case DItemNameType.EGPBush:
                    return "中托司";
                case DItemNameType.ReturnPin:
                    return "回针";
                case DItemNameType.ReturnPinScrew:
                    return "回针螺丝";
                case DItemNameType.PinBoardScrew:
                    return "针板螺丝";
                case DItemNameType.TopPanelScrew:
                    return "面板螺丝";
                case DItemNameType.BottomPanelScrew:
                    return "底板螺丝";
                case DItemNameType.SpaceBlockScrew:
                    return "方铁螺丝";
                case DItemNameType.GenericScrew:
                    return "公制螺丝";
                case DItemNameType.SpringHole:
                    return "弹簧孔";
                case DItemNameType.KOHole:
                    return "KO孔";
                case DItemNameType.SupportBlock:
                    return "支撑柱";
                case DItemNameType.GenericFineHole:
                    return "通用精孔";
                case DItemNameType.GenericRoughHole:
                    return "通用粗孔";
                case DItemNameType.MalePin:
                    return "销钉";
                case DItemNameType.SmallSP:
                    return "小拉杆";
                case DItemNameType.Meson:
                    return "水口介子";
                case DItemNameType.MesonScrew:
                    return "水介螺丝";
                case DItemNameType.ReturnPinScrewMeson:
                    return "回针介子";
            }
            return "";
        }

        //判断零件类型是否为零件
        public static Boolean JudgeItemIsScrew(DItemNameType Type)
        {
            Boolean F1 = Type == DItemNameType.ReturnPinScrew;
            Boolean F2 = Type == DItemNameType.PinBoardScrew;
            Boolean F3 = Type == DItemNameType.TopPanelScrew;
            Boolean F4 = Type == DItemNameType.BottomPanelScrew;
            Boolean F5 = Type == DItemNameType.SpaceBlockScrew;
            Boolean F6 = Type == DItemNameType.GenericScrew;
            Boolean F7 = Type == DItemNameType.MesonScrew;
            return F1 || F2 || F3 || F4 || F5 || F6 || F7;
        }

        public CAD_Point ComputedCenterLineFocal(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            CAD_Point resPoint = new CAD_Point();
            double a = 0, b = 0;
            int state = 0;
            if (line1.StartPoint.CustomerPoint.X != line1.EndPoint.CustomerPoint.X)
            {
                a = (line1.EndPoint.CustomerPoint.Y - line1.StartPoint.CustomerPoint.Y) 
                    / (line1.EndPoint.CustomerPoint.X - line1.StartPoint.CustomerPoint.X);
                state |= 1;
            }
            if (line2.StartPoint.CustomerPoint.X != line2.EndPoint.CustomerPoint.X)
            {
                b = (line2.EndPoint.CustomerPoint.Y - line2.StartPoint.CustomerPoint.Y) 
                    / (line2.EndPoint.CustomerPoint.X - line2.StartPoint.CustomerPoint.X);
                state |= 2;
            }
            switch (state)
            {
                case 0: //L1与L2都平行Y轴
                    {
                        if (line1.StartPoint.CustomerPoint.X == line2.StartPoint.CustomerPoint.X)
                        {
                            //throw new Exception("两条直线互相重合，且平行于Y轴，无法计算交点。");
                            resPoint.X = 0;
                            resPoint.Y = 0;
                            return resPoint;
                        }
                        else
                        {
                            //throw new Exception("两条直线互相平行，且平行于Y轴，无法计算交点。");
                            resPoint.X = 0;
                            resPoint.Y = 0;
                            return resPoint;
                        }
                    }
                case 1: //L1存在斜率, L2平行Y轴
                    {
                        double x = line2.StartPoint.CustomerPoint.X;
                        double y = (line1.StartPoint.CustomerPoint.X - x) * (-a) + line1.StartPoint.CustomerPoint.Y;
                        resPoint.X = x;
                        resPoint.Y = y;
                        return resPoint;
                    }
                case 2: //L1 平行Y轴，L2存在斜率
                    {
                        double x = line1.StartPoint.CustomerPoint.X;
                        //源code:line2.StartPoint * x + line2.StartPoint * line2.StartPoint.CustomerPoint.X + p3.Y;
                        double y = (line2.StartPoint.CustomerPoint.X - x) * (-b) + line2.StartPoint.CustomerPoint.Y;
                        resPoint.X = x;
                        resPoint.Y = y;
                        return resPoint;
                    }
                case 3: //L1，L2都存在斜率
                    {
                        if (a == b)
                        {
                            // throw new Exception("两条直线平行或重合，无法计算交点。");
                            resPoint.X = 0;
                            resPoint.Y = 0;
                            return resPoint;
                        }
                        double x = (a * line1.StartPoint.CustomerPoint.X - b * line2.StartPoint.CustomerPoint.X - 
                            line1.StartPoint.CustomerPoint.Y + line2.StartPoint.CustomerPoint.Y) / (a - b);
                        double y = a * x - a * line1.StartPoint.CustomerPoint.X + line1.StartPoint.CustomerPoint.Y;
                        resPoint.X = x;
                        resPoint.Y = y;
                        return resPoint;
                    }
            }
            resPoint.X = 0;
            resPoint.Y = 0;
            return resPoint;
        }

        //判断符合底板螺丝的集合元素的TD托位是否落在底板区域内(排除干扰项)
        public Boolean JudgeBpScrewTDInBpBoard(CSingleItem CSItem)
        {
            if (CSItem.InfoList.Count > 0)
            {
                List<CSinglePartItem> TDPartList = CSItem.InfoList.FindAll(item => item.ItemType == ItemPartCodeType.TD);
                if (TDPartList.Count > 0)
                {
                    double LMinY = TDPartList.Min(item => item.LLine.EndPoint.CustomerPoint.Y);
                    double RMinY = TDPartList.Min(item => item.RLine.EndPoint.CustomerPoint.Y);
                    double MinY = LMinY < RMinY ? LMinY : RMinY;
                    BoardSectionItem bpBoard = AssemblyShareData.ASectionList.Find(item => item.BoardCode.Equals("bpBoard"));
                    if (bpBoard != null)
                    {
                        double bpBoardOverY = bpBoard.OverheadLine.StartPoint.CustomerPoint.Y;
                        if (bpBoardOverY > MinY)
                            return true;
                    }
                }
            }
            return false;
        }

        //检测某点与线段是否近似连接
        public Boolean JudgePConnLine(MixedCAD_Point point, FullInfoLine line)
        {
            Boolean sameSXF = line.StartPoint.CustomerPoint.X - 1 <= point.CustomerPoint.X && point.CustomerPoint.X <= line.StartPoint.CustomerPoint.X + 1;
            Boolean sameSYF = line.StartPoint.CustomerPoint.Y - 1 <= point.CustomerPoint.Y && point.CustomerPoint.Y <= line.StartPoint.CustomerPoint.Y + 1;
            Boolean sameEXF = line.EndPoint.CustomerPoint.X - 1 <= point.CustomerPoint.X && point.CustomerPoint.X <= line.EndPoint.CustomerPoint.X + 1;
            Boolean sameEYF = line.EndPoint.CustomerPoint.Y - 1 <= point.CustomerPoint.Y && point.CustomerPoint.Y <= line.EndPoint.CustomerPoint.Y + 1;
            return (sameSXF && sameSYF) || (sameEXF && sameEYF);
        }

        //返回与点近似连接的线的另一端
        public MixedCAD_Point GetPJudgeLineAntherP(MixedCAD_Point point, FullInfoLine line)
        {
            Boolean sameSXF = line.StartPoint.CustomerPoint.X - 1 <= point.CustomerPoint.X && point.CustomerPoint.X <= line.StartPoint.CustomerPoint.X + 1;
            Boolean sameSYF = line.StartPoint.CustomerPoint.Y - 1 <= point.CustomerPoint.Y && point.CustomerPoint.Y <= line.StartPoint.CustomerPoint.Y + 1;
            Boolean sameEXF = line.EndPoint.CustomerPoint.X - 1 <= point.CustomerPoint.X && point.CustomerPoint.X <= line.EndPoint.CustomerPoint.X + 1;
            Boolean sameEYF = line.EndPoint.CustomerPoint.Y - 1 <= point.CustomerPoint.Y && point.CustomerPoint.Y <= line.EndPoint.CustomerPoint.Y + 1;
            Boolean F1 = sameSXF && sameSYF;
            Boolean F2 = sameEXF && sameEYF;
            if (F1)
                return line.EndPoint;
            if (F2)
                return line.StartPoint;
            return null;
        }

        //获取相邻线段的信息(精框)
        public FrameLineInfo GetFrameConnInfoByPL(CAD_Point point, FullInfoLine line)
        {
            FrameLineInfo Res = new FrameLineInfo();
            Boolean sameSXF = line.StartPoint.CustomerPoint.X - 0.02 <= point.X && point.X <= line.StartPoint.CustomerPoint.X + 0.02;
            Boolean sameSYF = line.StartPoint.CustomerPoint.Y - 0.02 <= point.Y && point.Y <= line.StartPoint.CustomerPoint.Y + 0.02;
            Boolean sameEXF = line.EndPoint.CustomerPoint.X - 0.02 <= point.X && point.X <= line.EndPoint.CustomerPoint.X + 0.02;
            Boolean sameEYF = line.EndPoint.CustomerPoint.Y - 0.02 <= point.Y && point.Y <= line.EndPoint.CustomerPoint.Y + 0.02;
            FrameLineType tempType = FrameLineType.NONE;
            if (line.LineType == CADLineType.XDirLine)
                tempType = FrameLineType.T;
            if (line.LineType == CADLineType.YDirLine)
                tempType = FrameLineType.V;
            if (sameSXF && sameSYF)
            {
                Res.FLineType = tempType;
                Res.TVLine = line;
                Res.ScanPType = ScanPointType.E;
            }
            if (sameEXF && sameEYF)
            {
                Res.FLineType = tempType;
                Res.TVLine = line;
                Res.ScanPType = ScanPointType.S;
            }
            return Res;
        }

        //检验某点与圆弧是否近似连接
        public Boolean JudgePConnArc(MixedCAD_Point point, MixedCAD_Arc arc)
        {
            Boolean sameSXF = arc.StartPoint.CustomerPoint.X - 1 <= point.CustomerPoint.X && point.CustomerPoint.X <= arc.StartPoint.CustomerPoint.X + 1;
            Boolean sameSYF = arc.StartPoint.CustomerPoint.Y - 1 <= point.CustomerPoint.Y && point.CustomerPoint.Y <= arc.StartPoint.CustomerPoint.Y + 1;
            Boolean sameEXF = arc.EndPoint.CustomerPoint.X - 1 <= point.CustomerPoint.X && point.CustomerPoint.X <= arc.EndPoint.CustomerPoint.X + 1;
            Boolean sameEYF = arc.EndPoint.CustomerPoint.Y - 1 <= point.CustomerPoint.Y && point.CustomerPoint.Y <= arc.EndPoint.CustomerPoint.Y + 1;
            return (sameSXF && sameSYF) || (sameEXF && sameEYF);
        }

        //返回与点近似连接的圆弧的另一端
        public MixedCAD_Point GetPJudgeArcAntherP(MixedCAD_Point point, MixedCAD_Arc arc)
        {
            Boolean sameSXF = arc.StartPoint.CustomerPoint.X - 1 <= point.CustomerPoint.X && point.CustomerPoint.X <= arc.StartPoint.CustomerPoint.X + 1;
            Boolean sameSYF = arc.StartPoint.CustomerPoint.Y - 1 <= point.CustomerPoint.Y && point.CustomerPoint.Y <= arc.StartPoint.CustomerPoint.Y + 1;
            Boolean sameEXF = arc.EndPoint.CustomerPoint.X - 1 <= point.CustomerPoint.X && point.CustomerPoint.X <= arc.EndPoint.CustomerPoint.X + 1;
            Boolean sameEYF = arc.EndPoint.CustomerPoint.Y - 1 <= point.CustomerPoint.Y && point.CustomerPoint.Y <= arc.EndPoint.CustomerPoint.Y + 1;
            Boolean F1 = sameSXF && sameSYF;
            Boolean F2 = sameEXF && sameEYF;
            if (F1)
                return arc.EndPoint;
            if (F2)
                return arc.StartPoint;
            return null;
        }

        //判断圆弧是否在某条直线上(X避空 Y避空 两种场景)
        public AngleType JudgeFArcXYBKOrNo(MixedCAD_Arc arc, CAD_Line line, FrameLineType FLType)
        {
            AngleType RES = AngleType.NONE;
            if (FLType == FrameLineType.T)
            {
                double SX = line.StartPoint.X;
                double EX = line.EndPoint.X;
                double Y = line.StartPoint.Y;
                double MinX = SX < EX ? SX : EX;
                double MaxX = SX > EX ? SX : EX;
                CAD_Point ASP = arc.StartPoint.CustomerPoint;
                CAD_Point AEP = arc.EndPoint.CustomerPoint;
                Boolean FX1 = Math.Round(MinX, 0) <= Math.Round(ASP.X, 0) && Math.Round(ASP.X, 0) <= Math.Round(MaxX, 0);
                Boolean FX2 = Math.Round(MinX, 0) <= Math.Round(AEP.X, 0) && Math.Round(AEP.X, 0) <= Math.Round(MaxX, 0);
                Boolean FY1 = Math.Round(Y, 0) == Math.Round(ASP.Y, 0);
                Boolean FY2 = Math.Round(Y, 0) == Math.Round(AEP.Y, 0);
                if (FX1 && FY1 && FX2 && FY2)
                    RES = AngleType.YBK;
            }
            if (FLType == FrameLineType.V)
            {
                double SY = line.StartPoint.Y;
                double EY = line.EndPoint.Y;
                double X = line.StartPoint.X;
                double MinY = SY < EY ? SY : EY;
                double MaxY = SY > EY ? SY : EY;
                CAD_Point ASP = arc.StartPoint.CustomerPoint;
                CAD_Point AEP = arc.EndPoint.CustomerPoint;
                Boolean FY1 = Math.Round(MinY, 0) <= Math.Round(ASP.Y, 0) && Math.Round(ASP.Y, 0) <= Math.Round(MaxY, 0);
                Boolean FY2 = Math.Round(MinY, 0) <= Math.Round(AEP.Y, 0) && Math.Round(AEP.Y, 0) <= Math.Round(MaxY, 0);
                Boolean FX1 = Math.Round(X, 0) == Math.Round(ASP.X, 0);
                Boolean FX2 = Math.Round(X, 0) == Math.Round(AEP.X, 0);
                if (FX1 && FY1 && FX2 && FY2)
                    RES = AngleType.XBK;
            }
            return RES;
        }

        public static string GetSYSBreCodeByFancy(string Fancytext)
        {
            string MSYS = null;
            List<string> PPsysList = new List<string>() { "DAH", "DAI", "DBH", "DBI", "DCH", "DCI",
                    "DDH", "DDI", "EAH", "EAI", "EBH", "EBI", "ECI", "EDH", "EDI" };
            List<string> SGsysList = new List<string>() { "SAH", "SAI", "SAT", "SBH", "SBI",
                    "SBT", "SCH", "SCI", "SCT", "SDH", "SDI", "SDT" };
            List<string> TPsysList = new List<string>() { "FAH", "FAI", "FCH", "FCI", "GAH", "GAI",
                    "GCH", "GCI" };
            if (PPsysList.Contains(Fancytext))
                MSYS = "PP";
            if (SGsysList.Contains(Fancytext))
                MSYS = "SG";
            if (TPsysList.Contains(Fancytext))
                MSYS = "TP";
            return MSYS;
        }


        //判断圆弧方向
        public AngleDir JudgeFrameAngleDir(MixedCAD_Arc Arc, CAD_Point TL, CAD_Point BL,
            CAD_Point TR, CAD_Point BR)
        {
            AngleDir RES = AngleDir.NONE;
            double TLX = Math.Abs(Arc.CenterPoint.CustomerPoint.X - TL.X);
            double TRX = Math.Abs(Arc.CenterPoint.CustomerPoint.X - TR.X);
            double BLX = Math.Abs(Arc.CenterPoint.CustomerPoint.X - BL.X);
            double BRX = Math.Abs(Arc.CenterPoint.CustomerPoint.X - BR.X);

            double TLY = Math.Abs(Arc.CenterPoint.CustomerPoint.Y - TL.Y);
            double TRY = Math.Abs(Arc.CenterPoint.CustomerPoint.Y - TR.Y);
            double BLY = Math.Abs(Arc.CenterPoint.CustomerPoint.Y - BL.Y);
            double BRY = Math.Abs(Arc.CenterPoint.CustomerPoint.Y - BR.Y);

            AngleInfo ATL = new AngleInfo();
            ATL.Dir = AngleDir.TL;
            ATL.XDis = TLX;
            ATL.YDis = TLY;
            AngleInfo ATR = new AngleInfo();
            ATR.Dir = AngleDir.TR;
            ATR.XDis = TRX;
            ATR.YDis = TRY;
            AngleInfo ABL = new AngleInfo();
            ABL.Dir = AngleDir.BL;
            ABL.XDis = BLX;
            ABL.YDis = BLY;
            AngleInfo ABR = new AngleInfo();
            ABR.Dir = AngleDir.BR;
            ABR.XDis = BRX;
            ABR.YDis = BRY;

            List<AngleInfo> AList = new List<AngleInfo>() { ATL, ABL, ATR, ABR };
            double ShortDX = AList.Min(item => item.XDis);
            double ShortDY = AList.Min(item => item.YDis);
            AngleInfo ARES = AList.Find(item => item.XDis == ShortDX && item.YDis == ShortDY);

            if (ARES != null)
                RES = ARES.Dir;
            return RES;
        }

        public class AngleInfo
        {
            public AngleDir Dir { get; set; } = AngleDir.NONE;
            //X距离
            public double XDis { get; set; }
            //Y距离
            public double YDis { get; set; }
        }

        //设置给ERP的精框数据
        public void SetFrameItemData(FrameItem FRItem, AngleDir AD, AngleType AT, double Raduis)
        {
            switch (AD)
            {
                case AngleDir.TR:
                    {
                        FRItem.TR_Radius = Math.Round(Raduis, 1);
                        FRItem.TR_Type = AT;
                        break;
                    }
                case AngleDir.TL:
                    {
                        FRItem.TL_Radius = Math.Round(Raduis, 1);
                        FRItem.TL_Type = AT;
                        break;
                    }
                case AngleDir.BR:
                    {
                        FRItem.BR_Radius = Math.Round(Raduis, 1);
                        FRItem.BR_Type = AT;
                        break;
                    }
                case AngleDir.BL:
                    {
                        FRItem.BL_Radius = Math.Round(Raduis, 1);
                        FRItem.BL_Type = AT; 
                        break;
                    }
            }
        }

        //判断圆弧是否在拉杆/导柱 直径外导套内 TO EDIT
        public Boolean JudgeArcConformDimbush(MixedCAD_Arc Arc, double BushTY, double BushBY, double DimLX, double DimRX, double BushLX, double BushRX)
        {
            DimLX = Math.Round(DimLX, 1);
            DimRX = Math.Round(DimRX, 1);
            BushLX = Math.Round(BushLX, 1);
            BushRX = Math.Round(BushRX, 1);
            BushTY = Math.Round(BushTY, 1);
            BushBY = Math.Round(BushBY, 1);
            Boolean CF = (BushLX < Arc.CenterPoint.TransSplitPoint.X && Arc.CenterPoint.TransSplitPoint.X < DimLX)
                                                || (DimRX < Arc.CenterPoint.TransSplitPoint.X && Arc.CenterPoint.TransSplitPoint.X < BushRX);
            Boolean BTF = BushBY < Arc.CenterPoint.CustomerPoint.Y && Arc.CenterPoint.CustomerPoint.Y < BushTY;
            return Arc.Radius > 2 && CF && BTF;
        }

        //通过圆弧起点 终点 中心坐标 设置圆弧开口方向
        public void SetArcDirListBySEPoint(List<MixedCAD_Arc> ArcList)
        {
            if (ArcList.Count > 0)
            {
                for (int i = 0; i < ArcList.Count; i++)
                {
                    CAD_Point StartPoint = ArcList[i].StartPoint.CustomerPoint;
                    CAD_Point EndPoint = ArcList[i].EndPoint.CustomerPoint;
                    CAD_Point CenterPoint = ArcList[i].CenterPoint.CustomerPoint;

                    double midX = (StartPoint.X + EndPoint.X) / 2;
                    double midY = (StartPoint.Y + EndPoint.Y) / 2;

                    if (midX > CenterPoint.X && midY > CenterPoint.Y)
                        ArcList[i].Dir = AngleDir.TR;
                    else if (midX < CenterPoint.X && midY > CenterPoint.Y)
                        ArcList[i].Dir = AngleDir.TL;
                    else if (midX < CenterPoint.X && midY < CenterPoint.Y)
                        ArcList[i].Dir = AngleDir.BR;
                    else if (midX > CenterPoint.X && midY < CenterPoint.Y)
                        ArcList[i].Dir = AngleDir.BL;
                }
            }
        }

        //断定 一组板没有四个方向的圆弧
        public Boolean OneBoardNoBArcFourDic(List<MixedCAD_Arc> OneBoardBushArcList)
        {
            Boolean CountF = OneBoardBushArcList.Count == 4;
            Boolean TLF = OneBoardBushArcList.FindIndex(item => item.Dir == AngleDir.TL) != -1;
            Boolean TRF = OneBoardBushArcList.FindIndex(item => item.Dir == AngleDir.TR) != -1;
            Boolean BLF = OneBoardBushArcList.FindIndex(item => item.Dir == AngleDir.BL) != -1;
            Boolean BRF = OneBoardBushArcList.FindIndex(item => item.Dir == AngleDir.BR) != -1;
            return CountF && !(TLF && TRF && BLF && BRF);
        }

        //判断同一X坐标的一组竖线 是否可以被相连
        public Boolean SameXCanConn(List<MixedCAD_Line> VList)
        {
            MixedCAD_Line FLine = VList[0];
            MixedCAD_Line LLine = VList[VList.Count - 1];
            double MidSY = Math.Round(FLine.EndPoint.CustomerPoint.Y, 0);
            double MidEY = Math.Round(LLine.StartPoint.CustomerPoint.Y, 0);
            Boolean F1 = MidSY <= MidEY;
            if (F1)
                return true;
            else
            {
                Boolean F2 = VList.FindIndex(item => MidSY <= Math.Round(item.StartPoint.CustomerPoint.Y, 0)
                && Math.Round(item.EndPoint.CustomerPoint.Y, 0) <= MidEY) != -1;
                if (F2)
                    return true;
            }
            return false;
        }

        //Find ItemPart Most Appear X
        public double FindItemAVSplitCX(List<CSinglePartItem> ItemPartList)
        {
            Dictionary<double,int> frequency = ItemPartList.GroupBy(item => item.AVSplitCX)
                                 .ToDictionary(group => group.Key, group => group.Count());
            int maxCount = frequency.Values.Max();
            Dictionary<double, int> mostFrequentItems = frequency.Where(pair => pair.Value == maxCount)
                                             .ToDictionary(pair => pair.Key, pair => pair.Value);
            return mostFrequentItems.Keys.FirstOrDefault();
        }

        public double FindItemAVCustomerCX(List<CSinglePartItem> ItemPartList)
        {
            Dictionary<double, int> frequency = ItemPartList.GroupBy(item => item.AVCustomerCX)
                                 .ToDictionary(group => group.Key, group => group.Count());
            int maxCount = frequency.Values.Max();
            Dictionary<double, int> mostFrequentItems = frequency.Where(pair => pair.Value == maxCount)
                                             .ToDictionary(pair => pair.Key, pair => pair.Value);
            return mostFrequentItems.Keys.FirstOrDefault();
        }

        public Boolean JudgeItemPartFallOutInterval(List<CSinglePartItem> ItemList, double LX, double RX)
        {
            int Count = ItemList.Count;
            int FCount = ItemList.FindAll(item => item.TVCPX < LX || item.TVCPX > RX).Count();
            return Count == FCount;
        }

        //查找
        public int GetOneBoardIndex(string boardName)
        {
            return AssemblyShareData.ASectionList.FindIndex(item => item.BoardCode.Equals(boardName));
        }

        //判断竖线 是否 不会太远
        public Boolean JudgeTwoYLineNoTooOverDis(MixedCAD_Line line1, MixedCAD_Line line2)
        {
            double line1SY = line1.StartPoint.CustomerPoint.Y;
            double line1EY = line1.EndPoint.CustomerPoint.Y;
            double line2SY = line2.StartPoint.CustomerPoint.Y;
            double line2EY = line2.EndPoint.CustomerPoint.Y;
            double Diff = 5;
            double line1MinY = line1SY < line1EY ? line1SY : line1EY;
            double line1MaxY = line1SY > line1EY ? line1SY : line1EY;
            double line2MinY = line2SY < line2EY ? line2SY : line2EY;
            double line2MaxY = line2SY > line2EY ? line2SY : line2EY;
            Boolean F1 = line1MinY - Diff <= line2MinY && line2MinY <= line1MinY + Diff;
            Boolean F2 = line1MaxY - Diff <= line2MaxY && line2MaxY <= line1MaxY + Diff;
            return F1 && F2;
        }

        //判断两坐标近似相等 (用于孔Step3策略对比)
        public Boolean JudgeHoleAndStandardHoleNearSame(MixedCAD_Point point, StandardHoleData hole)
        {
            Boolean F1 = point.CustomerPoint.X - 1 <= hole.ItemW && hole.ItemW <= point.CustomerPoint.X + 1;
            Boolean F2 = point.CustomerPoint.Y - 1 <= hole.ItemL && hole.ItemL <= point.CustomerPoint.Y + 1;
            return F1 && F2;
        }

        //GP 分中坐标 比较器
        public List<MixedCAD_Point> GPHolePointCDDissComparator(CAD_Point refCP,List<MixedCAD_Point> HolePointList)
        {
            List<MixedCAD_Point> ResList = new List<MixedCAD_Point>();
            List<TempFilterByCDInfo> cdList = new List<TempFilterByCDInfo>();
            if(HolePointList.Count > 0)
            {
                for(int i = 0; i < HolePointList.Count;i++)
                {
                    double diffX = Math.Abs(HolePointList[i].CustomerPoint.X - refCP.X);
                    double diffY = Math.Abs(HolePointList[i].CustomerPoint.Y - refCP.Y);
                    double CDDiff = Math.Sqrt(diffX * diffX + diffY * diffY);
                    TempFilterByCDInfo Item = new TempFilterByCDInfo();
                    Item.pointInfo = HolePointList[i];
                    Item.CD = CDDiff;
                    cdList.Add(Item);
                }
                if(cdList.Count > 0)
                {
                    cdList = cdList.OrderBy(item => item.CD).ToList();
                    cdList = cdList.GetRange(0, 4);
                    ResList = cdList.Select(item => item.pointInfo).ToList();
                }
               
            }
            return ResList;
        }

        //SP 分中坐标 比较器
        public List<MixedCAD_Point> SPHolePointCDDissComparator(CAD_Point refCP, List<MixedCAD_Point> HolePointList)
        {
            List<MixedCAD_Point> ResList = new List<MixedCAD_Point>();
            List<TempFilterByCDInfo> cdList = new List<TempFilterByCDInfo>();
            if (HolePointList.Count > 0)
            {
                for (int i = 0; i < HolePointList.Count; i++)
                {
                    double diffX = Math.Abs(HolePointList[i].CustomerPoint.X - refCP.X);
                    double diffY = Math.Abs(HolePointList[i].CustomerPoint.Y - refCP.Y);
                    double CDDiff = Math.Sqrt(diffX * diffX + diffY * diffY);
                    TempFilterByCDInfo Item = new TempFilterByCDInfo();
                    Item.pointInfo = HolePointList[i];
                    Item.CD = CDDiff;
                    cdList.Add(Item);
                }
                if (cdList.Count > 0)
                {
                    cdList = cdList.OrderByDescending(item => item.CD).ToList();
                    cdList = cdList.GetRange(0, 4);
                    ResList = cdList.Select(item => item.pointInfo).ToList();
                }

            }
            return ResList;
        }

        //手动模式 我司内部吊令规则
        public double MMoldTypePullingRule(string MouldStr, string BoardCode, double PlateThick, string Type = null)
        {
            int M8 = 8;
            int M10 = 10;
            int M12 = 12;
            int M16 = 16;
            int M20 = 20;
            int M24 = 24;
            int M30 = 30;
            int M36 = 36;
            int M42 = 42;
            int M48 = 48;

            double Res = 0;
 
            string targetWStr = MouldStr.Substring(0, 2);
            string targetLStr = MouldStr.Substring(2, MouldStr.Length - 2);
            double WSize = double.Parse(targetWStr);
            double LSize = double.Parse(targetLStr);

            // A/B板
            if (BoardCode.Equals("aBoard") || BoardCode.Equals("bBoard"))
            {
                //1515~2030  M12
                if (15 <= WSize && WSize <= 20)
                {
                    if (WSize < 20)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (1515 <= matchSize && matchSize < 2030)
                            return M12;
                    }
                    if (WSize == 20)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 2030)
                                return M12;
                        }
                    }
                }

                //2031~2340 M16
                if (20 <= WSize && WSize <= 23)
                {
                    if (WSize < 23)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (2031 <= matchSize && matchSize < 2340)
                            return M16;
                    }
                    if (WSize == 23)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 2340)
                                return M16;
                        }
                    }
                }

                //2525~2940 M16
                if (25 <= WSize && WSize <= 29)
                {
                    if (WSize < 29)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (2525 <= matchSize && matchSize < 2940)
                            return M16;
                    }
                    if (WSize == 29)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 2940)
                                return M16;
                        }
                    }
                }

                //3030~3035 M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3030 <= matchSize && matchSize <= 3035)
                            return M16;
                    }
                }

                //3040~3060(->3090) M20
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3040 <= matchSize && matchSize <= 3090)
                            return M20;
                    }
                }

                //3335~3360 M20
                if (33 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3335 <= matchSize && matchSize <= 3360)
                            return M20;
                    }
                }

                //3535~3570 M20
                if (35 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3535 <= matchSize && matchSize <= 3570)
                            return M20;
                    }
                }

                //4040~4044 M24
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4040 <= matchSize && matchSize <= 4044)
                            return M24;
                    }
                }

                //4045~4050 M24
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M24;
                    }
                }

                //4055~5070 M30
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M30;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M30;
                        }
                    }
                }

                //5555~5570 M30
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M30;
                    }
                }


                //5575~6080 M36
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M36;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M36;
                        }
                    }
                }

                //6565~6580 M36
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M36;
                    }
                }

                //6585~65100 M42
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M42;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M42;
                    }
                }

                //7070~7075 M36
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M36;
                    }
                }

                //7080-70100 M42
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M42;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M42;
                    }
                }

                //8080~8085 M42
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M42;
                    }
                }

                //8090~80100 M48
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M48;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M48;
                    }
                }

            }

            //水口面板
            if (BoardCode.Equals("cpBoard"))
            {
                if (Type != null)
                {
                    //1515~2030 M12
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M12;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M12;
                            }
                        }
                    }

                    //2031~2340 M12
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M12;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M12;
                            }
                        }
                    }

                    //2525~2940 M12
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M12;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M12;
                            }
                        }
                    }
                }

                //3030~3035 M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3030 <= matchSize && matchSize <= 3035)
                            return M16;
                    }
                }

                //3040~3060(->3090) M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3040 <= matchSize && matchSize <= 3090)
                            return M16;
                    }
                }

                //3335~3360 M16
                if (33 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3335 <= matchSize && matchSize <= 3360)
                            return M16;
                    }
                }

                //3535~3570 M16
                if (35 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3535 <= matchSize && matchSize <= 3570)
                            return M16;
                    }
                }

                //4040~4044 M20
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4040 <= matchSize && matchSize <= 4044)
                            return M20;
                    }
                }

                //4045~4050 M20
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M20;
                    }
                }

                //4055~5070 M24
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M24;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M24;
                        }
                    }
                }

                //5555~5570 M24
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M24;
                    }
                }

                //5575~6080 M24
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M24;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M24;
                        }
                    }
                }

                //6565~6580 M30
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M30;
                    }
                }

                //6585~65100 M30
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M30;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M30;
                    }
                }

                //7070~7075 M30
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M30;
                    }
                }

                //7080-70100 M36
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M36;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M36;
                    }
                }

                //8080~8085 M36
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M36;
                    }
                }

                //8090~80100 M36
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M36;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M36;
                    }
                }

            }

            //托板 
            if (BoardCode.Equals("spBoard"))
            {
                List<ManualBoardItem> BoardList = AssemblyShareData.MSectionList;
                List<ManualBoardItem> aBoardList = BoardList.FindAll(item => item.BoardCode.Equals("aBoard")).ToList();
                List<ManualBoardItem> bBoardList = BoardList.FindAll(item => item.BoardCode.Equals("bBoard")).ToList();
                if (aBoardList.Count > 0 && bBoardList.Count > 0)
                {
                    double aMinThick = aBoardList.Min(item => item.PlateThick);
                    double bMinThick = bBoardList.Min(item => item.PlateThick);
                    double abMinThick = aMinThick < bMinThick ? aMinThick : bMinThick;
                    double Thick = PlateThick;
                    if (Thick >= abMinThick && abMinThick != 0)
                    {
                        ManualBoardItem ABItem = BoardList.Find(item => item.BoardCode.Equals("aBoard") || item.BoardCode.Equals("bBoard")
                         && item.PlateThick == abMinThick);
                        string ABCode = ABItem.BoardCode;
                        double ABThick = ABItem.PlateThick;
                        return MMoldTypePullingRule(MouldStr, ABCode, ABThick, Type);
                    }
                    else if (Thick >= 40)
                        return 16;
                }
                else
                {
                    if (Type != null)
                    {
                        //1515~2030 M16
                        if (15 <= WSize && WSize <= 20)
                        {
                            if (WSize < 20)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (1515 <= matchSize && matchSize < 2030)
                                    return M16;
                            }
                            if (WSize == 20)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2030)
                                        return M16;
                                }
                            }
                        }

                        //2031~2340 M16
                        if (20 <= WSize && WSize <= 23)
                        {
                            if (WSize < 23)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (2031 <= matchSize && matchSize < 2340)
                                    return M16;
                            }
                            if (WSize == 23)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2340)
                                        return M16;
                                }
                            }
                        }

                        //2525~2940 M16
                        if (25 <= WSize && WSize <= 29)
                        {
                            if (WSize < 29)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (2525 <= matchSize && matchSize < 2940)
                                    return M16;
                            }
                            if (WSize == 29)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2940)
                                        return M16;
                                }
                            }
                        }

                        //3030~3035 M16
                        if (30 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3030 <= matchSize && matchSize <= 3035)
                                    return M16;
                            }
                        }

                        //3040~3060(->3090) M16
                        if (30 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3040 <= matchSize && matchSize <= 3090)
                                    return M16;
                            }
                        }

                        //3335~3360 M16
                        if (33 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3335 <= matchSize && matchSize <= 3360)
                                    return M16;
                            }
                        }

                        //3535~3570 M16
                        if (35 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3535 <= matchSize && matchSize <= 3570)
                                    return M16;
                            }
                        }

                        //4040~4044 M16
                        if (40 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (4040 <= matchSize && matchSize <= 4044)
                                    return M16;
                            }
                        }

                    }

                    //4045~4050 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4045 <= matchSize && matchSize <= 4050)
                                return M16;
                        }
                    }

                    //4055~5070 M24
                    if (40 <= WSize && WSize <= 50)
                    {
                        if (WSize < 50)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4055 <= matchSize && matchSize < 5070)
                                return M24;
                        }
                        if (WSize == 50)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 5070)
                                    return M24;
                            }
                        }
                    }

                    //5555~5570 M24
                    if (55 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5555 <= matchSize && matchSize <= 5570)
                                return M24;
                        }
                    }

                    //5575~6080 M30
                    if (55 <= WSize && WSize <= 60)
                    {
                        if (WSize < 60)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5575 <= matchSize && matchSize < 6080)
                                return M30;
                        }
                        if (WSize == 60)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 6080)
                                    return M30;
                            }
                        }
                    }

                    //6565~6580 M30
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6565 <= matchSize && matchSize <= 6580)
                                return M30;
                        }
                    }

                    //6585~65100 M30
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6585 <= matchSize)
                                return M30;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M30;
                        }
                    }

                    //7070~7075 M30
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7070 <= matchSize && matchSize <= 7075)
                                return M30;
                        }
                    }


                    //7080-70100 M36
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7080 <= matchSize)
                                return M36;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M36;
                        }
                    }

                    //8080~8085 M36
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8080 <= matchSize && matchSize <= 8085)
                                return M36;
                        }
                    }

                    //8090~80100 M36
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8090 <= matchSize)
                                return M36;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M36;
                        }
                    }
                }
            }

            //面板
            if (BoardCode.Equals("tpBoard"))
            {
                if (Type != null)
                {
                    //1515~2030 M10
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M10;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M10;
                            }
                        }
                    }

                    //2031~2340 M12
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M12;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M12;
                            }
                        }
                    }

                    //2525~2940 M12
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M12;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M12;
                            }
                        }
                    }

                    //3030~3035 M16
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3030 <= matchSize && matchSize <= 3035)
                                return M16;
                        }
                    }

                    //3040~3060(->3090) M16
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3040 <= matchSize && matchSize <= 3090)
                                return M16;
                        }
                    }

                    //3335~3360 M16
                    if (33 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3335 <= matchSize && matchSize <= 3360)
                                return M16;
                        }
                    }

                    //3535~3570 M16
                    if (35 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3535 <= matchSize && matchSize <= 3570)
                                return M16;
                        }
                    }

                    //4040~4044 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4040 <= matchSize && matchSize <= 4044)
                                return M16;
                        }
                    }
                }

                //4045~4050 M16
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M16;
                    }
                }

                //4055~5070 M16
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M16;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M16;
                        }
                    }
                }

                //5555~5570 M16
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M16;
                    }
                }

                //5575~6080 M16
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M16;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M16;
                        }
                    }
                }

                //6565~6580 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M16;
                    }
                }

                //6585~65100 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M16;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M16;
                    }
                }

                //7070~7075 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M20;
                    }
                }

                //7080-70100 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

                //8080~8085 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M20;
                    }
                }

                //8090~80100 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

            }

            //底板
            if (BoardCode.Equals("bpBoard"))
            {
                if (Type != null)
                {
                    //1515~2030 M10
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M10;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M10;
                            }
                        }
                    }

                    //2031~2340  M12
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M12;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M12;
                            }
                        }
                    }

                    //2525~2940 M12
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M12;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M12;
                            }
                        }
                    }

                }

                //赠送
                //3030~3035 M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3030 <= matchSize && matchSize <= 3035)
                            return M16;
                    }
                }

                //3040~3060(->3090) M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3040 <= matchSize && matchSize <= 3090)
                            return M16;
                    }
                }

                //3335~3360 M16
                if (33 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3335 <= matchSize && matchSize <= 3360)
                            return M16;
                    }
                }

                //3535~3570 M16
                if (35 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3535 <= matchSize && matchSize <= 3570)
                            return M16;
                    }
                }

                //4040~4044 M16
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4040 <= matchSize && matchSize <= 4044)
                            return M16;
                    }
                }

                //非赠送
                //4045~4050 M16
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M16;
                    }
                }

                //4055~5070 M16
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M16;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M16;
                        }
                    }
                }

                //5555~5570 M16
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M16;
                    }
                }

                //5575~6080 M16
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M16;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M16;
                        }
                    }
                }

                //6565~6580 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M16;
                    }
                }

                //6585~65100 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M16;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M16;
                    }
                }

                //7070~7075 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M20;
                    }
                }

                //7080-70100 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

                //8080~8085 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M20;
                    }
                }

                //8090~80100 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

            }

            //水口推板 推板 流道板
            if (BoardCode.Equals("rspBoard") || BoardCode.Equals("stBoard"))
            {
                List<ManualBoardItem> BoardList = AssemblyShareData.MSectionList;
                List<ManualBoardItem> aBoardList = BoardList.FindAll(item => item.BoardCode.Equals("aBoard")).ToList();
                List<ManualBoardItem> bBoardList = BoardList.FindAll(item => item.BoardCode.Equals("bBoard")).ToList();
                if (aBoardList.Count > 0 && bBoardList.Count > 0)
                {
                    double aMinThick = aBoardList.Min(item => item.PlateThick);
                    double bMinThick = bBoardList.Min(item => item.PlateThick);
                    double abMinThick = aMinThick < bMinThick ? aMinThick : bMinThick;
                    double Thick = PlateThick;
                    if (Thick >= abMinThick && abMinThick != 0)
                    {
                        ManualBoardItem ABItem = BoardList.Find(item => (item.BoardCode.Equals("aBoard") || item.BoardCode.Equals("bBoard"))
                         && item.PlateThick == abMinThick);
                        string ABCode = ABItem.BoardCode;
                        double ABThick = ABItem.PlateThick;
                        return MMoldTypePullingRule(MouldStr, ABCode, ABThick, Type);
                    }
                    else if (Thick >= 40)
                        return 16;
                }
                else
                {
                    if (Type != null)
                    {

                        //1515~2030 M10
                        if (15 <= WSize && WSize <= 20)
                        {
                            if (WSize < 20)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (1515 <= matchSize && matchSize < 2030)
                                    return M10;
                            }
                            if (WSize == 20)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2030)
                                        return M10;
                                }
                            }
                        }

                        //2031~2340 M10
                        if (20 <= WSize && WSize <= 23)
                        {
                            if (WSize < 23)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (2031 <= matchSize && matchSize < 2340)
                                    return M10;
                            }
                            if (WSize == 23)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2340)
                                        return M10;
                                }
                            }
                        }

                        //2525~2940 M10
                        if (25 <= WSize && WSize <= 29)
                        {
                            if (WSize < 29)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (2525 <= matchSize && matchSize < 2940)
                                    return M10;
                            }
                            if (WSize == 29)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2940)
                                        return M10;
                                }
                            }
                        }

                        //3030~3035 M16
                        if (30 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3030 <= matchSize && matchSize <= 3035)
                                    return M16;
                            }
                        }

                        //3040~3060(->3090) M16
                        if (30 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3040 <= matchSize && matchSize <= 3090)
                                    return M16;
                            }
                        }
                    }


                    //3335~3360 M16
                    if (33 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3335 <= matchSize && matchSize <= 3360)
                                return M16;
                        }
                    }

                    //3535~3570 M16
                    if (35 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3535 <= matchSize && matchSize <= 3570)
                                return M16;
                        }
                    }

                    //4040~4044 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4040 <= matchSize && matchSize <= 4044)
                                return M16;
                        }
                    }

                    //4045~4050 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4045 <= matchSize && matchSize <= 4050)
                                return M16;
                        }
                    }

                    //4055~5070 M20
                    if (40 <= WSize && WSize <= 50)
                    {
                        if (WSize < 50)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4055 <= matchSize && matchSize < 5070)
                                return M20;
                        }
                        if (WSize == 50)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 5070)
                                    return M20;
                            }
                        }
                    }

                    //5555~5570 M20
                    if (55 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5555 <= matchSize && matchSize <= 5570)
                                return M20;
                        }
                    }

                    //5575~6080 M20
                    if (55 <= WSize && WSize <= 60)
                    {
                        if (WSize < 60)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5575 <= matchSize && matchSize < 6080)
                                return M20;
                        }
                        if (WSize == 60)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 6080)
                                    return M20;
                            }
                        }
                    }

                    //6565~6580 M20
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6565 <= matchSize && matchSize <= 6580)
                                return M20;
                        }
                    }

                    //6585~65100 M20
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6585 <= matchSize)
                                return M20;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M20;
                        }
                    }

                    //7070~7075 M24
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7070 <= matchSize && matchSize <= 7075)
                                return M24;
                        }
                    }

                    //7080-70100 M24
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7080 <= matchSize)
                                return M24;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M24;
                        }
                    }

                    //8080~8085 M24
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8080 <= matchSize && matchSize <= 8085)
                                return M24;
                        }
                    }

                    //8090~80100 M24
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8090 <= matchSize)
                                return M24;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M24;
                        }
                    }

                }
            }

            //方铁
            if (BoardCode.Equals("fangtie"))
            {
                if (Type != null)
                {
                    //1515~2030 M12
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M12;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M12;
                            }
                        }
                    }

                    //2031~2340 M12
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M12;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M12;
                            }
                        }
                    }

                    //2525~2940 M12
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M12;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M12;
                            }
                        }
                    }

                    //3030~3035 M12
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3030 <= matchSize && matchSize <= 3035)
                                return M12;
                        }
                    }

                    //3040~3060(->3090) M12
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3040 <= matchSize && matchSize <= 3090)
                                return M12;
                        }
                    }

                    //3335~3360 M16
                    if (33 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3335 <= matchSize && matchSize <= 3360)
                                return M16;
                        }
                    }

                    //3535~3570 M16
                    if (35 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3535 <= matchSize && matchSize <= 3570)
                                return M16;
                        }
                    }

                    //4040~4044 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4040 <= matchSize && matchSize <= 4044)
                                return M16;
                        }
                    }
                }

                //4045~4050  M16
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M16;
                    }
                }

                //4055~5070 M16
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M16;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M16;
                        }
                    }
                }

                //5555~5570 M16
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M16;
                    }
                }

                //5575~6080 M16
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M16;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M16;
                        }
                    }
                }

                //6565~6580 M16 
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M16;
                    }
                }

                //6585~65100 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M16;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M16;
                    }
                }

                //7070~7075 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M20;
                    }
                }

                //7080-70100 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

                //8080~8085 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M20;
                    }
                }

                //8090~80100 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }
            }

            //上下针板
            if (BoardCode.Equals("epBoard") || BoardCode.Equals("fpBoard"))
            {
                if (Type != null)
                {
                    //1515~2030 M8
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M8;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M8;
                            }
                        }
                    }

                    //2031~2340 M10
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M10;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M10;
                            }
                        }
                    }

                    //2525~2940 M10
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M10;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M10;
                            }
                        }
                    }

                    //3030~3035 M10
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3030 <= matchSize && matchSize <= 3035)
                                return M10;
                        }
                    }

                    //3040~3060(->3090) M10
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3040 <= matchSize && matchSize <= 3090)
                                return M10;
                        }
                    }

                    //3335~3360 M10
                    if (33 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3335 <= matchSize && matchSize <= 3360)
                                return M10;
                        }
                    }

                    //3535~3570 M10
                    if (35 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3535 <= matchSize && matchSize <= 3570)
                                return M10;
                        }
                    }

                    //4040~4044 M12
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4040 <= matchSize && matchSize <= 4044)
                                return M12;
                        }
                    }

                    //4045~4050 M12
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4045 <= matchSize && matchSize <= 4050)
                                return M12;
                        }
                    }

                    // 4055~5070 M16
                    if (40 <= WSize && WSize <= 50)
                    {
                        if (WSize < 50)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4055 <= matchSize && matchSize < 5070)
                                return M16;
                        }
                        if (WSize == 50)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 5070)
                                    return M16;
                            }
                        }
                    }

                    //5555~5570 M16
                    if (55 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5555 <= matchSize && matchSize <= 5570)
                                return M16;
                        }
                    }

                    //5575~6080 M16
                    if (55 <= WSize && WSize <= 60)
                    {
                        if (WSize < 60)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5575 <= matchSize && matchSize < 6080)
                                return M16;
                        }
                        if (WSize == 60)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 6080)
                                    return M16;
                            }
                        }
                    }

                    //6565~6580 M16
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6565 <= matchSize && matchSize <= 6580)
                                return M16;
                        }
                    }

                    //6585~65100 M16
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6585 <= matchSize)
                                return M16;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M16;
                        }
                    }

                    //7070~7075 M16
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7070 <= matchSize && matchSize <= 7075)
                                return M16;
                        }
                    }

                    //7080-70100 M16
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7080 <= matchSize)
                                return M16;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M16;
                        }
                    }

                    //8080~8085 M20
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8080 <= matchSize && matchSize <= 8085)
                                return M20;
                        }
                    }

                    //8090~80100 M20
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8090 <= matchSize)
                                return M20;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M20;
                        }
                    }

                }
            }
            return Res;
        }

        //上传前检测整套模吊令
        public Boolean CheckMoldPullingParamBeforeUpload()
        {
            List<BoardSectionItem> BoardList = AssemblyShareData.AUIBlueSectionList;
            
            if (BoardList.Count > 0)
            {
                for(int i = 0; i < BoardList.Count; i++)
                {
                    double pullingSize = AutoSetPulllingParam(BoardList[i].BoardCode, BoardList[i].PlateThick, null);
                    Boolean F1 = pullingSize != -1;
                    Boolean F2 = BoardList[i].Hanging.HangingParam.Dim != pullingSize;
                    Boolean noSameF = F1 && F2;
                    if (noSameF)
                        return false;
                }
            }
            return true;
        }

        //自动补齐设置吊令参数
        public double AutoSetPulllingParam(string BoardCode, double PlateThick, string Type = null)
        {
            int M8 = 8;
            int M10 = 10;
            int M12 = 12;
            int M16 = 16;
            int M20 = 20;
            int M24 = 24;
            int M30 = 30;
            int M36 = 36;
            int M42 = 42;
            int M48 = 48;

            string targetWStr = MoldBaseShare.Width.ToString();
            int WSize = int.Parse(targetWStr.Substring(0, 2));
            string targetLStr = MoldBaseShare.Length.ToString();

            // A/B板
            if (BoardCode.Equals("aBoard") || BoardCode.Equals("bBoard"))
            {
                //1515~2030 M12
                if (15 <= WSize && WSize <= 20)
                {
                    if(WSize < 20)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (1515 <= matchSize && matchSize < 2030)
                            return M12;
                    }
                    if(WSize == 20)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if ( matchSize <= 2030)
                                return M12;
                        }
                    }
                }

                //2031~2340 M16
                if (20 <= WSize && WSize <= 23)
                {
                    if (WSize < 23)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (2031 <= matchSize && matchSize < 2340)
                            return M16;
                    }
                    if (WSize == 23)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 2340)
                                return M16;
                        }
                    }
                }

                //2525~2940 M16
                if (25 <= WSize && WSize <= 29)
                {
                    if (WSize < 29)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (2525 <= matchSize && matchSize < 2940)
                            return M16;
                    }
                    if (WSize == 29)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 2940)
                                return M16;
                        }
                    }
                }

                //3030~3035 M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3030 <= matchSize && matchSize <= 3035)
                            return M16;
                    }
                }

                //3040~3060(->3090) M20
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3040 <= matchSize && matchSize <= 3090)
                            return M20;
                    }
                }

                //3335~3360 M20
                if (33 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3335 <= matchSize && matchSize <= 3360)
                            return M20;
                    }
                }

                //3535~3570 M20
                if (35 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3535 <= matchSize && matchSize <= 3570)
                            return M20;
                    }
                }

                //4040~4044 M24
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4040 <= matchSize && matchSize <= 4044)
                            return M24;
                    }
                }

                //4045~4050 M24
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M24;
                    }
                }

                //4055~5070 M30
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M30;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M30;
                        }
                    }
                }

                //5555~5570 M30
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M30;
                    }
                }

                //5575~6080 M36
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M36;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M36;
                        }
                    }
                }

                //6565~6580 M36
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M36;
                    }
                }

                //6585~65100 M42
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M42;
                    }
                    else
                    {
                        string targetMathLStr =  targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M42;
                    }
                }

                //7070~7075 M36
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M36;
                    }
                }

                //7080-70100 M42
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M42;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M42;
                    }
                }

                //8080~8085 M42
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M42;
                    }
                }

                //8090~80100 M48
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M48;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M48;
                    }
                }

            }

            //水口面板
            if (BoardCode.Equals("cpBoard"))
            {
                if (Type != null)
                {
                    //1515~2030 M12
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M12;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M12;
                            }
                        }
                    }

                    //2031~2340 M12
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M12;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M12;
                            }
                        }
                    }

                    //2525~2940 M12
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M12;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M12;
                            }
                        }
                    }
                }

                //3030~3035 M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3030 <= matchSize && matchSize <= 3035)
                            return M16;
                    }
                }

                //3040~3060(->3090) M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3040 <= matchSize && matchSize <= 3090)
                            return M16;
                    }
                }

                //3335~3360 M16
                if (33 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3335 <= matchSize && matchSize <= 3360)
                            return M16;
                    }
                }

                //3535~3570 M16
                if (35 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3535 <= matchSize && matchSize <= 3570)
                            return M16;
                    }
                }

                //4040~4044 M20
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4040 <= matchSize && matchSize <= 4044)
                            return M20;
                    }
                }

                //4045~4050 M20
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M20;
                    }
                }

                //4055~5070 M24
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M24;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M24;
                        }
                    }
                }

                //5555~5570 M24
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M24;
                    }
                }

                //5575~6080 M24
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M24;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M24;
                        }
                    }
                }

                //6565~6580 M30
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M30;
                    }
                }

                //6585~65100 M30
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M30;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M30;
                    }
                }

                //7070~7075 M30
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M30;
                    }
                }

                //7080-70100 M36
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M36;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M36;
                    }
                }

                //8080~8085 M36
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M36;
                    }
                }

                //8090~80100 M36
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M36;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M36;
                    }
                }

            }

            //托板
            if (BoardCode.Equals("spBoard"))
            {
                List<BoardSectionItem> BoardList = AssemblyShareData.ASectionList;
                double aMinThick = BoardList.FindAll(item => item.BoardCode.Equals("aBoard")).Min(item => item.PlateThick);
                double bMinThick = BoardList.FindAll(item => item.BoardCode.Equals("bBoard")).Min(item => item.PlateThick);
                double abMinThick = aMinThick < bMinThick ? aMinThick : bMinThick;
                double Thick = PlateThick;
                if (Thick >= abMinThick)
                {
                    BoardSectionItem ABItem = BoardList.Find(item => item.BoardCode.Equals("aBoard") || item.BoardCode.Equals("bBoard")
                     && item.PlateThick == abMinThick);
                    string ABCode = ABItem.BoardCode;
                    double ABThick = ABItem.PlateThick;
                    return AutoSetPulllingParam(ABCode, ABThick);
                }
                else if (Thick >= 40)
                    return 16;
                else
                {
                    if (Type != null)
                    {
                        //1515~2030 M16
                        if (15 <= WSize && WSize <= 20)
                        {
                            if (WSize < 20)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (1515 <= matchSize && matchSize < 2030)
                                    return M16;
                            }
                            if (WSize == 20)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2030)
                                        return M16;
                                }
                            }
                        }

                        //2031~2340 M16
                        if (20 <= WSize && WSize <= 23)
                        {
                            if (WSize < 23)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (2031 <= matchSize && matchSize < 2340)
                                    return M16;
                            }
                            if (WSize == 23)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2340)
                                        return M16;
                                }
                            }
                        }

                        //2525~2940 M16
                        if (25 <= WSize && WSize <= 29)
                        {
                            if (WSize < 29)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (2525 <= matchSize && matchSize < 2940)
                                    return M16;
                            }
                            if (WSize == 29)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2940)
                                        return M16;
                                }
                            }
                        }

                        //3030~3035 M16
                        if (30 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3030 <= matchSize && matchSize <= 3035)
                                    return M16;
                            }
                        }

                        //3040~3060(->3090) M16
                        if (30 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3040 <= matchSize && matchSize <= 3090)
                                    return M16;
                            }
                        }

                        //3335~3360 M16
                        if (33 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3335 <= matchSize && matchSize <= 3360)
                                    return M16;
                            }
                        }

                        //3535~3570 M16
                        if (35 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3535 <= matchSize && matchSize <= 3570)
                                    return M16;
                            }
                        }

                        //4040~4044 M16
                        if (40 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (4040 <= matchSize && matchSize <= 4044)
                                    return M16;
                            }
                        }

                    }

                    //4045~4050 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4045 <= matchSize && matchSize <= 4050)
                                return M16;
                        }
                    }

                    //4055~5070 M24
                    if (40 <= WSize && WSize <= 50)
                    {
                        if (WSize < 50)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4055 <= matchSize && matchSize < 5070)
                                return M24;
                        }
                        if (WSize == 50)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 5070)
                                    return M24;
                            }
                        }
                    }

                    //5555~5570 M24
                    if (55 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5555 <= matchSize && matchSize <= 5570)
                                return M24;
                        }
                    }

                    //5575~6080 M30
                    if (55 <= WSize && WSize <= 60)
                    {
                        if (WSize < 60)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5575 <= matchSize && matchSize < 6080)
                                return M30;
                        }
                        if (WSize == 60)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 6080)
                                    return M30;
                            }
                        }
                    }

                    //6565~6580 M30
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6565 <= matchSize && matchSize <= 6580)
                                return M30;
                        }
                    }

                    //6585~65100 M30
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6585 <= matchSize)
                                return M30;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M30;
                        }
                    }

                    //7070~7075 M30
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7070 <= matchSize && matchSize <= 7075)
                                return M30;
                        }
                    }


                    //7080-70100 M36
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7080 <= matchSize)
                                return M36;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M36;
                        }
                    }

                    //8080~8085 M36
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8080 <= matchSize && matchSize <= 8085)
                                return M36;
                        }
                    }

                    //8090~80100 M36
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8090 <= matchSize)
                                return M36;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M36;
                        }
                    }

                }
            }

            //面板
            if (BoardCode.Equals("tpBoard"))
            {
                if (Type != null)
                {
                    //1515~2030 M10
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M10;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M10;
                            }
                        }
                    }

                    //2031~2340 M12
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M12;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M12;
                            }
                        }
                    }

                    //2525~2940 M12
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M12;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M12;
                            }
                        }
                    }

                    //3030~3035 M16
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3030 <= matchSize && matchSize <= 3035)
                                return M16;
                        }
                    }

                    //3040~3060(->3090) M16
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3040 <= matchSize && matchSize <= 3090)
                                return M16;
                        }
                    }

                    //3335~3360 M16
                    if (33 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3335 <= matchSize && matchSize <= 3360)
                                return M16;
                        }
                    }

                    //3535~3570 M16
                    if (35 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3535 <= matchSize && matchSize <= 3570)
                                return M16;
                        }
                    }

                    //4040~4044 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4040 <= matchSize && matchSize <= 4044)
                                return M16;
                        }
                    }
                }

                //4045~4050 M16
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M16;
                    }
                }

                //4055~5070 M16
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M16;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M16;
                        }
                    }
                }

                //5555~5570 M16
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M16;
                    }
                }

                //5575~6080 M16
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M16;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M16;
                        }
                    }
                }

                //6565~6580 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M16;
                    }
                }

                //6585~65100 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M16;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M16;
                    }
                }

                //7070~7075 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M20;
                    }
                }

                //7080-70100 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

                //8080~8085 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M20;
                    }
                }

                //8090~80100 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

            }

            //底板
            if (BoardCode.Equals("bpBoard"))
            {
                if (Type != null)
                {
                    //1515~2030 M10
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M10;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M10;
                            }
                        }
                    }

                    //2031~2340  M12
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M12;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M12;
                            }
                        }
                    }

                    //2525~2940 M12
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M12;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M12;
                            }
                        }
                    }

                }

                //赠送
                //3030~3035 M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3030 <= matchSize && matchSize <= 3035)
                            return M16;
                    }
                }

                //3040~3060(->3090) M16
                if (30 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3040 <= matchSize && matchSize <= 3090)
                            return M16;
                    }
                }

                //3335~3360 M16
                if (33 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3335 <= matchSize && matchSize <= 3360)
                            return M16;
                    }
                }

                //3535~3570 M16
                if (35 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (3535 <= matchSize && matchSize <= 3570)
                            return M16;
                    }
                }

                //4040~4044 M16
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4040 <= matchSize && matchSize <= 4044)
                            return M16;
                    }
                }

                //非赠送
                //4045~4050 M16
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M16;
                    }
                }

                //4055~5070 M16
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M16;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M16;
                        }
                    }
                }

                //5555~5570 M16
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M16;
                    }
                }

                //5575~6080 M16
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M16;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M16;
                        }
                    }
                }

                //6565~6580 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M16;
                    }
                }

                //6585~65100 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M16;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M16;
                    }
                }

                //7070~7075 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M20;
                    }
                }

                //7080-70100 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

                //8080~8085 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M20;
                    }
                }

                //8090~80100 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

            }

            //水口推板 推板 流道板
            if (BoardCode.Equals("rspBoard") || BoardCode.Equals("stBoard") || BoardCode.Equals("rBoard"))
            {
                List<BoardSectionItem> BoardList = AssemblyShareData.ASectionList;
                double aMinThick = BoardList.FindAll(item => item.BoardCode.Equals("aBoard")).Min(item => item.PlateThick);
                double bMinThick = BoardList.FindAll(item => item.BoardCode.Equals("bBoard")).Min(item => item.PlateThick);
                double abMinThick = aMinThick < bMinThick ? aMinThick : bMinThick;
                double Thick = PlateThick;
                if (Thick >= abMinThick)
                {
                    BoardSectionItem ABItem = BoardList.Find(item => item.BoardCode.Equals("aBoard") || item.BoardCode.Equals("bBoard")
                     && item.PlateThick == abMinThick);
                    string ABCode = ABItem.BoardCode;
                    double ABThick = ABItem.PlateThick;
                    return AutoSetPulllingParam(ABCode, ABThick);
                }
                else if (Thick >= 40)
                    return 16;
                else
                {
                    if (Type != null)
                    {

                        //1515~2030 M10
                        if (15 <= WSize && WSize <= 20)
                        {
                            if (WSize < 20)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (1515 <= matchSize && matchSize < 2030)
                                    return M10;
                            }
                            if (WSize == 20)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2030)
                                        return M10;
                                }
                            }
                        }

                        //2031~2340 M10
                        if (20 <= WSize && WSize <= 23)
                        {
                            if (WSize < 23)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (2031 <= matchSize && matchSize < 2340)
                                    return M10;
                            }
                            if (WSize == 23)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2340)
                                        return M10;
                                }
                            }
                        }

                        //2525~2940 M10
                        if (25 <= WSize && WSize <= 29)
                        {
                            if (WSize < 29)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (2525 <= matchSize && matchSize < 2940)
                                    return M10;
                            }
                            if (WSize == 29)
                            {
                                Boolean comfirmF = targetLStr.Length < 4;
                                if (comfirmF)
                                {
                                    string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                    int matchSize = int.Parse(matchStr);
                                    if (matchSize <= 2940)
                                        return M10;
                                }
                            }
                        }

                        //3030~3035 M16
                        if (30 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3030 <= matchSize && matchSize <= 3035)
                                    return M16;
                            }
                        }

                        //3040~3060(->3090) M16
                        if (30 == WSize)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (3040 <= matchSize && matchSize <= 3090)
                                    return M16;
                            }
                        }
                    }


                    //3335~3360 M16
                    if (33 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3335 <= matchSize && matchSize <= 3360)
                                return M16;
                        }
                    }

                    //3535~3570 M16
                    if (35 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3535 <= matchSize && matchSize <= 3570)
                                return M16;
                        }
                    }

                    //4040~4044 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4040 <= matchSize && matchSize <= 4044)
                                return M16;
                        }
                    }

                    //4045~4050 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4045 <= matchSize && matchSize <= 4050)
                                return M16;
                        }
                    }

                    //4055~5070 M20
                    if (40 <= WSize && WSize <= 50)
                    {
                        if (WSize < 50)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4055 <= matchSize && matchSize < 5070)
                                return M20;
                        }
                        if (WSize == 50)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 5070)
                                    return M20;
                            }
                        }
                    }

                    //5555~5570 M20
                    if (55 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5555 <= matchSize && matchSize <= 5570)
                                return M20;
                        }
                    }

                    //5575~6080 M20
                    if (55 <= WSize && WSize <= 60)
                    {
                        if (WSize < 60)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (5575 <= matchSize && matchSize < 6080)
                                return M20;
                        }
                        if (WSize == 60)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 6080)
                                    return M20;
                            }
                        }
                    }

                    //6565~6580 M20
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6565 <= matchSize && matchSize <= 6580)
                                return M20;
                        }
                    }

                    //6585~65100 M20
                    if (65 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (6585 <= matchSize)
                                return M20;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M20;
                        }
                    }

                    //7070~7075 M24
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7070 <= matchSize && matchSize <= 7075)
                                return M24;
                        }
                    }

                    //7080-70100 M24
                    if (70 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (7080 <= matchSize)
                                return M24;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M24;
                        }
                    }

                    //8080~8085 M24
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8080 <= matchSize && matchSize <= 8085)
                                return M24;
                        }
                    }

                    //8090~80100 M24
                    if (80 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (8090 <= matchSize)
                                return M24;
                        }
                        else
                        {
                            string targetMathLStr = targetLStr.Substring(0, 3);
                            int matchLSize = int.Parse(targetMathLStr);
                            if (matchLSize <= 100)
                                return M24;
                        }
                    }

                }
            }

            //方铁
            if (BoardCode.Equals("fangtie"))
            {
                if (Type != null)
                {
                    //1515~2030 M12
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M12;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M12;
                            }
                        }
                    }

                    //2031~2340 M12
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M12;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M12;
                            }
                        }
                    }

                    //2525~2940 M12
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M12;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M12;
                            }
                        }
                    }

                    //3030~3035 M12
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3030 <= matchSize && matchSize <= 3035)
                                return M12;
                        }
                    }

                    //3040~3060(->3090) M12
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3040 <= matchSize && matchSize <= 3090)
                                return M12;
                        }
                    }

                    //3335~3360 M16
                    if (33 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3335 <= matchSize && matchSize <= 3360)
                                return M16;
                        }
                    }

                    //3535~3570 M16
                    if (35 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3535 <= matchSize && matchSize <= 3570)
                                return M16;
                        }
                    }

                    //4040~4044 M16
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4040 <= matchSize && matchSize <= 4044)
                                return M16;
                        }
                    }
                }

                //4045~4050  M16
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M16;
                    }
                }

                //4055~5070 M16
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M16;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M16;
                        }
                    }
                }

                //5555~5570 M16
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M16;
                    }
                }

                //5575~6080 M16
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M16;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M16;
                        }
                    }
                }

                //6565~6580 M16 
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M16;
                    }
                }

                //6585~65100 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M16;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M16;
                    }
                }

                //7070~7075 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M20;
                    }
                }

                //7080-70100 M20
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

                //8080~8085 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M20;
                    }
                }

                //8090~80100 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }
            }

            //上下针板
            if (BoardCode.Equals("epBoard") || BoardCode.Equals("fpBoard"))
            {
                if (Type != null)
                {
                    //1515~2030 M8
                    if (15 <= WSize && WSize <= 20)
                    {
                        if (WSize < 20)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (1515 <= matchSize && matchSize < 2030)
                                return M8;
                        }
                        if (WSize == 20)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2030)
                                    return M8;
                            }
                        }
                    }

                    //2031~2340 M10
                    if (20 <= WSize && WSize <= 23)
                    {
                        if (WSize < 23)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2031 <= matchSize && matchSize < 2340)
                                return M10;
                        }
                        if (WSize == 23)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2340)
                                    return M10;
                            }
                        }
                    }

                    //2525~2940 M10
                    if (25 <= WSize && WSize <= 29)
                    {
                        if (WSize < 29)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (2525 <= matchSize && matchSize < 2940)
                                return M10;
                        }
                        if (WSize == 29)
                        {
                            Boolean comfirmF = targetLStr.Length < 4;
                            if (comfirmF)
                            {
                                string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                                int matchSize = int.Parse(matchStr);
                                if (matchSize <= 2940)
                                    return M10;
                            }
                        }
                    }

                    //3030~3035 M10
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3030 <= matchSize && matchSize <= 3035)
                                return M10;
                        }
                    }

                    //3040~3060(->3090) M10
                    if (30 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3040 <= matchSize && matchSize <= 3090)
                                return M10;
                        }
                    }

                    //3335~3360 M10
                    if (33 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3335 <= matchSize && matchSize <= 3360)
                                return M10;
                        }
                    }

                    //3535~3570 M10
                    if (35 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (3535 <= matchSize && matchSize <= 3570)
                                return M10;
                        }
                    }

                    //4040~4044 M12
                    if (40 == WSize)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (4040 <= matchSize && matchSize <= 4044)
                                return M12;
                        }
                    }

                }

                //4045~4050 M12
                if (40 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4045 <= matchSize && matchSize <= 4050)
                            return M12;
                    }
                }

                // 4055~5070 M16
                if (40 <= WSize && WSize <= 50)
                {
                    if (WSize < 50)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (4055 <= matchSize && matchSize < 5070)
                            return M16;
                    }
                    if (WSize == 50)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 5070)
                                return M16;
                        }
                    }
                }

                //5555~5570 M16
                if (55 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5555 <= matchSize && matchSize <= 5570)
                            return M16;
                    }
                }

                //5575~6080 M16
                if (55 <= WSize && WSize <= 60)
                {
                    if (WSize < 60)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (5575 <= matchSize && matchSize < 6080)
                            return M16;
                    }
                    if (WSize == 60)
                    {
                        Boolean comfirmF = targetLStr.Length < 4;
                        if (comfirmF)
                        {
                            string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                            int matchSize = int.Parse(matchStr);
                            if (matchSize <= 6080)
                                return M16;
                        }
                    }
                }

                //6565~6580 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6565 <= matchSize && matchSize <= 6580)
                            return M16;
                    }
                }

                //6585~65100 M16
                if (65 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (6585 <= matchSize)
                            return M16;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M16;
                    }
                }

                //7070~7075 M16
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7070 <= matchSize && matchSize <= 7075)
                            return M16;
                    }
                }

                //7080-70100 M16
                if (70 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (7080 <= matchSize)
                            return M16;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M16;
                    }
                }

                //8080~8085 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8080 <= matchSize && matchSize <= 8085)
                            return M20;
                    }
                }

                //8090~80100 M20
                if (80 == WSize)
                {
                    Boolean comfirmF = targetLStr.Length < 4;
                    if (comfirmF)
                    {
                        string matchStr = targetWStr.Substring(0, 2) + targetLStr.Substring(0, 2);
                        int matchSize = int.Parse(matchStr);
                        if (8090 <= matchSize)
                            return M20;
                    }
                    else
                    {
                        string targetMathLStr = targetLStr.Substring(0, 3);
                        int matchLSize = int.Parse(targetMathLStr);
                        if (matchLSize <= 100)
                            return M20;
                    }
                }

            }
            return -1;
        }

        //回针 长度补充规则  理论长度 新规
        public static double RPTheoryLRepRule(double customerL)
        {
            double resNum = customerL;
            int compNum = (int)(customerL % 10);
            if (compNum == 0 || compNum == 5)
                return resNum;
            else if (1 <= compNum && compNum <= 4)
                return resNum - compNum + 5;
            else if (5 < compNum && compNum <= 9)
                return resNum - compNum + 10;
            return resNum;
        }

        //GP 长度补充规则  理论长度 新规
        public double GPTheoryLRepRule(int customerL)
        {
            double Res = customerL;
            Boolean smallF = customerL < 200;
            if (smallF)
                Res = GPLessThan200TheoryLRepRule(customerL);
            else
                Res = GPGreaterThan200TheoryLRepRule(customerL);
            return Res;
        }

        //SP 长度补充规则  理论长度 新规
        public double SPTheoryLRepRule(int customerL)
        {
            double Res = customerL;
            Boolean smallF = customerL < 200;
            if (smallF)
                Res = SPLessThan200TheoryLRepRule(customerL);
            else
                Res = SPGreaterThan200TheoryLRepRule(customerL);
            return Res;
        }

        //GP 长度补充规则 <200 -> 理论长度
        public double GPLessThan200TheoryLRepRule(int customerL)
        {
            double resNum = customerL;
            int compNum = customerL % 10;
            if (compNum == 0 || compNum == 5)
                return resNum;
            else if (1 <= compNum && compNum <= 4)
                return resNum - compNum;
            else if (5 < compNum && compNum <= 9)
                return resNum - compNum + 5;
            return resNum;
        }

        //GP 长度补充规则 >200 -> 理论长度
        public double GPGreaterThan200TheoryLRepRule(int customerL)
        {
            double resNum = customerL;
            int compNum = customerL / 10;
            resNum = compNum * 10;
            return resNum;
        }

        //SP 长度补充规则  < 200 -> 理论长度
        public double SPLessThan200TheoryLRepRule(int customerL)
        {
            double resNum = customerL;
            int compNum = customerL % 10;
            int dieNum = customerL / 10;
            if (compNum == 0 || compNum == 5)
                return customerL;
            else if (1 <= compNum && compNum <= 4)
                resNum = dieNum * 10 + 5;
            else if (5 < compNum && compNum <= 9)
                resNum = (dieNum + 1) * 10;
            return resNum;
        }

        //SP 长度补充规则 >200 -> 理论长度
        public double SPGreaterThan200TheoryLRepRule(int customerL)
        {
            double resNum = customerL;
            int compNum = customerL % 10;
            int dieNum = customerL / 10;
            if(compNum <= 5)
                resNum = dieNum * 10;
            else
                resNum = (dieNum + 1) * 10;
            return resNum;
        }

        /**导柱/拉杆 导套 客图长度 -> 理论长度
         * A套/B套的长度：长度0/3/5/8不更改，其他往标准0/5靠，如52就按50显示，54按55显示；56/57就按55取，59往上靠0
         */
        public double BushCustomerLTranToTheoryL(int customerL)
        {
            double resNum = customerL;
            int remNum = customerL % 10;
            int intPartNum = customerL - remNum;
            if (remNum == 0 || remNum == 3 || remNum == 5 || remNum == 8)
                return resNum;
            if (remNum == 1 || remNum == 1)
                return intPartNum;
            if (remNum == 4)
                return intPartNum + 5;
            if (remNum == 6 || remNum == 7)
                return intPartNum + 5;
            if (remNum == 9)
                return intPartNum + 10;
            return resNum;
        }

        //根据拉杆Dim 推算介子Thick厚度
        public double CalculateMisTBySpDim(double spDim)
        {
            if (0 <= spDim && spDim <= 16)
                return 8;
            if (16 < spDim && spDim <= 20)
                return 10;
            if (20 < spDim && spDim <= 25)
                return 12;
            if (25 < spDim && spDim <= 30)
                return 14;
            if (35 <= spDim && spDim <= 45)
                return 16;
            if (50 <= spDim && spDim <= 70)
                return 20;
            return -1;
        }

        //根据拉杆Dim 推算水介螺丝Dim
        public double CalculateMisScrewDimBySpDim(double spDim)
        {
            if (0 <= spDim && spDim <= 16)
                return 8;
            if (16 < spDim && spDim <= 20)
                return 10;
            if (20 < spDim && spDim <= 25)
                return 12;
            if (30 <= spDim && spDim <= 45)
                return 16;
            if (50 <= spDim && spDim <= 70)
                return 20;
            return -1;
        }

        //根据拉杆Dim 推算介子螺丝Thick厚度
        public double CalculateMisScrewTBySpDim(double spDim)
        {
            if (0 <= spDim && spDim <= 16)
                return 25;
            if (16 < spDim && spDim <= 20)
                return 30;
            if (20 < spDim && spDim <= 25)
                return 35;
            if (30 <= spDim && spDim <= 70)
                return 45;
            return -1;
        }

        //过滤中文
        public string FilterChinseStr(string Input)
        {
            string Pattern = @"[\u4e00-\u9fa5]+";
            string Output = Regex.Replace(Input, Pattern, string.Empty);
            return Output;
        }

        //判断曲线最高点 最低点 落在某两个点之间
        public Boolean JudgeCurveInPartArea(RPCutOffInfo CutOffInfo, MixedCAD_Curve Cur)
        {
            double diff = 5;
            double CurMinX = Math.Round(Cur.MinXPoint.CustomerPoint.X, 0) - diff;
            double CurMaxX = Math.Round(Cur.MaxXPoint.CustomerPoint.X, 0) + diff;
            double CurMaxY = Cur.MaxYPoint.CustomerPoint.Y;
            double? ItemMaxY = null;
            double ItemLX = Math.Round(CutOffInfo.LPoint.X, 0);
            double ItemRX = Math.Round(CutOffInfo.RPoint.X, 0);

            if (CutOffInfo.traitType == RPPointTraitType.LHight)
                ItemMaxY = CutOffInfo.LPoint.Y;
            if (CutOffInfo.traitType == RPPointTraitType.RHight)
                ItemMaxY = CutOffInfo.RPoint.Y;

            if (ItemMaxY != null)
            {
                Boolean F1 = ItemRX <= CurMaxX;
                Boolean F2 = CurMinX <= ItemLX;
                Boolean F3 = ItemMaxY <= CurMaxY;
                return F1 && F2 && F3;
            }
            return false;
        }

        //选择集框中区域坐标 用于记录标出用户框中的图纸区域
        public PictureFrameCondiInfo ViewSelectAreaCondication(Extents3d APList)
        {
            Point3d minPoint = APList.MinPoint;
            Point3d maxPoint = APList.MaxPoint;
            double p1X = minPoint.X;
            double p1Y = minPoint.Y;
            double p2X = maxPoint.X;
            double p2Y = maxPoint.Y;
            double LX = p1X < p2X ? p1X : p2X;
            double RX = p1X > p2X ? p1X : p2X;
            double TY = p1Y > p2Y ? p1Y : p2Y;
            double BY = p1Y < p2Y ? p1Y : p2Y;
            PictureFrameCondiInfo Info = new PictureFrameCondiInfo();
            Info.LX = LX;
            Info.RX = RX;
            Info.TY = TY;
            Info.BY = BY;
            return Info;
        }

        //将两个选择集的坐标合并成一个大的外边界矩形坐标
        public static PictureFrameCondiInfo dwgSelectAreaCondication(PictureFrameCondiInfo Info1, PictureFrameCondiInfo Info2)
        {
            PictureFrameCondiInfo Info = new PictureFrameCondiInfo();
            double? LX1 = null;
            double? LX2 = null;
            double? RX1 = null;
            double? RX2 = null;
            double? TY1 = null;
            double? TY2 = null;
            double? BY1 = null;
            double? BY2 = null;
            double? LX = null;
            double? RX = null;
            double? TY = null;
            double? BY = null;
            if (Info1.LX != null)
                 LX1 = (double)Info1.LX;
            if (Info2.LX != null)
                LX2 = (double)Info2.LX;
            if (Info1.RX != null)
                RX1 = (double)Info1.RX;
            if (Info2.RX != null)
                RX2 = (double)Info2.RX;
            if (Info1.TY != null)
                TY1 = (double)Info1.TY;
            if (Info2.TY != null)
                TY2 = (double)Info2.TY;
            if (Info1.BY != null)
                BY1 = (double)Info1.BY;
            if (Info2.BY != null)
                BY2 = (double)Info2.BY;
            if(LX1 != null && LX2 != null)
               LX = (double)LX1 < (double)LX2 ? (double)LX1 : (double)LX2;
            if (RX1 != null && RX2 != null)
                RX = (double)RX1 > (double)RX2 ? (double)RX1 : (double)RX2;
            if (TY1 != null && TY2 != null)
                TY = (double)TY1 > (double)TY2 ? (double)TY1 : (double)TY2;
            if (BY1 != null && BY2 != null)
                BY = (double)BY1 < (double)BY2 ? (double)BY1 : (double)BY2;
            Info.LX = LX;
            Info.RX = RX;
            Info.TY = TY;
            Info.BY = BY;
            return Info;
        }

        //回针加牙规格
        public double RPTeechSep(double rpDim)
        {
            double Res = -1;
            if (rpDim == 15)
                Res = 8;
            if (rpDim == 20)
                Res = 10;
            if (rpDim == 25)
                Res = 10;
            if (rpDim == 30)
                Res = 16;
            return Res;
        }

        //判断拉令 花式&型号 是否符合 柔性线标准
        public Boolean IsFlexibleWireHaing(string targetMS)
        {
            Boolean Res = false;
            List<string> fxMoldSizeList = new List<string>() {
                "M3035SCI070080",
                "M3030SCI070080",
                "M3040SCI070080",
                "M2530SCI070080",
                "M2530SCI060080",
                "M2020SCI050060",
                "M2535SCI070080",
                "M2025SCI060070",
                "M3035SCI070090",
                "M2525SCI060080",
                "M2535SCI060080",
                "M3035SCI060080",
                "M2735SCI070080",
                "M2730SCI070080",
                "M2020SCI050070",
                "M3040SCI070090",
                "M3030SCI060080",
                "M2025SCI050070",
                "M2020SCI060070",
                "M2525SCI060070",
                "M2530SCI060070",
                "M3035SCI080090",
                "M3040SCI080090",
                "M2525SCI070080",
                "M2023SCI050070",
                "M2030SCI060080",
                "M2025SCI060080",
                "M2730SCI060080",
                "M2030SCI060070",
                "M3045SCI070090",
                "M2540SCI070080",
                "M3540SCI070090",
                "M2023SCI060070",
                "M3540SCI070080",
                "M2325SCI060070",
                "M2540SCI060080",
                "M2735SCI060080",
                "M2527SCI060080",
                "M3030SCI070090",
                "M3040SCI060080",
                "M3535SCI070080",
                "M2530SCI070090",
                "M2325SCI060080",
                "M3535SCI070090",
                "M3045SCI070080",
                "M2330SCI060080",
                "M3540SCI080090",
                "M2740SCI070080",
                "M2330SCI060070",
                "M2527SCI070080",
                "M2025SCI050060",
                "M2535SCI070090",
                "M3535SCI080090",
                "M3030SCI080090",
                "M3545SCI080090",
                "M3335SCI070080",
                "M2530SCI060090",
                "M2030SCI050070",
                "M2327SCI060080",
                "M3040FCI080090",
                "M2335SCI060080",
                "M2527SCI060070",
                "M3545SCI070090",
                "M3045SCI080090",
                "M3032SCI070080",
                "M2020SCI060080",
                "M3035SCI060090",
                "M2535SCI060070",
                "M3030SCI060090",
                "M2030SCI070080",
                "M2535SCI080090",
                "M2327SCI060070",
                "M2323SCI050070",
                "M2330SCI070080",
                "M2023SCI060080",
                "M2535SCI060090",
                "M2735SCI070090",
                "M2323SCI060070",
                "M3335SCI070090",
                "M3032SCI060080",
                "M2730SCI060070",
                "M3340SCI070090",
                "M3035FCI070090",
                "M2323SCI060080",
                "M2025SCI070080",
                "M2525SCI050070",
                "M3035SCI080080",
                "M2740SCI060080",
                "M2335SCI070080",
                "M3545SCI070080",
                "M3040SCI060090",
                "M2530SCI080090",
                "M2530SCI050070",
                "M3030SCI060070",
                "M2530FCI060080",
                "M2023SCI050060",
                "M2540SCI070090",
                "M3340SCI070080",
                "M3035SCI070070",
                "M2740SCI070090",
                "M3340SCI080090",
                "M2535SCI080080",
                "M3040FCI070090",
                "M3035SCI060070",
                "M2325SCI050070",
                "M2525SCI060090",
                "M2730SCI070090",
                "M2540SCI080090",
                "M2735SCI080090",
                "M2530SCI080080",
                "M3335SCI060080",
                "M3050SCI070090",
                "M3040SCI080080",
                "M2327SCI050070",
                "M2035SCI060080",
                "M2030SCI050060",
                "M2545SCI060080",
                "M3535SCI060080",
                "M2020SCI050080",
                "M2035SCI060070",
                "M2525SCI050080",
                "M2327SCI070080",
                "M3045SCI060080",
                "M2325SCI070080",
                "M2530SCI050080",
                "M2530FCI060090",
                "M2025SCI050080",
                "M2735SCI060070",
                "M2735SCI080080",
                "M2525SCI070090",
                "M3540SCI060080",
                "M3032SCI070090",
                "M2035SCI070080",
                "M2730SCI060090",
                "M3535SCI060090",
                "M3540SCI080100",
                "M3335SCI080090",
                "M3045SCI060090",
                "M2030SCI050080",
                "M2545SCI070090",
                "M2335SCI060070",
                "M2740SCI080090",
                "M2540SCI060090",
                "M2330SCI050070",
                "M3030SCI080080",
                "M3035FCI060080",
                "M3545FCI070090",
                "M3345SCI070090",
                "M2530FCI070080",
                "M2530SCI070070",
                "M2735SCI060090",
                "M2545SCI080090",
                "M2545SCI070080",
                "M3050SCI080090",
                "M2525FCI060080",
                "M2527SCI060090",
                "M2535SCI050070",
                "M3540FCI070090",
                "M4040SCI070090",
                "M3550SCI080090",
                "M3040FCI070080",
                "M2540SCI060070",
                "M2730SCI080080",
                "M2730SCI080090",
                "M2527SCI050080",
                "M3545SCI080100",
                "M2535FCI060080",
                "M2035SCI050070",
                "M2527SCI070090",
                "M3550SCI070090",
                "M3035SCI050080",
                "M2020SCI070080",
                "M2330SCI060090",
                "M3335SCI060090",
                "M3535SCI080080",
                "M3540SCH090100",
                "M3540SCI060090",
                "M3540FCI080090",
                "M3540SCH080090",
                "M3035SCH070080",
                "M3345SCI080090",
                "M3345SCI070080",
                "M2535SCI070070",
                "M3545SCI090100",
                "M3535SCI070100",
                "M3045SCI080080",
                "M3045SCH080090",
                "M4040SCI080090",
                "M2527SCI050070",
                "M2030SCI060090",
                "M2330SCI070090",
                "M2335SCI070090",
                "M3540SCI080080",
                "M3045FCI070090",
                "M3340SCI060080",
                "M3040SCI060070",
                "M2535FCI070080",
                "M2525SCI080080",
                "M2330FCI060080",
                "M3540SCI090090",
                "M3535SCI080100",
                "M2025FCI060070",
                "M2735FCI060080",
                "M3032SCI060090",
                "M3040SCH070080",
                "M3030FCI060080",
                "M2540SCI080080",
                "M2740SCI060090",
                "M3045SCI070100",
                "M3030SCI050080",
                "M2025FCI050070",
                "M3545SCI070100",
                "M4040SCI070080",
                "M3035SCI070100",
                "M4040SCI080100",
                "M3545SCI060080",
                "M2020SCI060060",
                "M2525SCI050060",
                "M3040SCI070070",
                "M3045SCI080100",
                "M2535FCI070090",
                "M2023SCI070080",
                "M4045SCI080090",
                "M3535FCI080090",
                "M3535SCI070070",
                "M3040SCH080090",
                "M3340SCI060090",
                "M2735FCI070090",
                "M3335SCI080080",
                "M2535SCI050080",
                "M3050SCI080100",
                "M4045SCI080100",
                "M3032SCI080080",
                "M2330SCI050080",
                "M2025SCI070070",
                "M3540SCH070080",
                "M3540SCI070100",
                "M3550SCI070100",
                "M2325SCI050080",
                "M2335SCI060090",
                "M2545SCI060090",
                "M2527SCI080080",
                "M3550SCI080100",
                "M3030SCH070080",
                "M3030SCI050070",
                "M2740SCI080080",
                "M3030SCI070070",
                "M3045SCI090100",
                "M3035FCI060090",
                "M2335SCI050070",
                "M2327SCI050080",
                "M2023SCI050080",
                "M3030FCI070080",
                "M2025FCI060080",
                "M3540SCI070070",
                "M3035FCI070080",
                "M2730SCI050070",
                "M2525SCI070070",
                "M2735FCI070080",
                "M2540FCI060080",
                "M4040SCI070100",
                "M2325SCI050060",
                "M2335SCI080080",
                "M2530FCI070090",
                "M4045SCI070090",
                "M4045SCI090100",
                "M2330SCI070070",
                "M2730SCI050080",
                "M2540SCI050080",
                "M2527SCI070070",
                "M2023SCI070070",
                "M2025SCI060090",
                "M2545SCI060070",
                "M4050SCI070090",
                "M4050SCI080100",
                "M3540FCI070080",
                "M3340SCI080080",
                "M2730SCI070070",
                "M2030SCI070090",
                "M2335SCI050080",
                "M4050SCI080090",
                "M2030FCI060080",
                "M2535FCI060090",
                "M3545SCI060090",
                "M2540FCI070080",
                "M2540FCI070090",
                "M2730FCI060080",
                "M3030FCI070090",
                "M4040SCI090100",
                "M4045SCI070100",
                "M4050SCI070100",
                "M2735SCI070070",
                "M2323SCI050060",
                "M2540SCI070100",
                "M3535SCI060070",
                "M2325SCI060090",
                "M2035SCI070090",
                "M2530SCI050060",
                "M2325SCI070090",
                "M2327SCI060090",
                "M2530FCI080090",
                "M4045SCI070080",
                "M3545FCI080090",
                "M2530SCI070100",
                "M2540SCI050070",
                "M2735FCI060090",
                "M2530FCI060070",
                "M3045SCI060070",
                "M3045SCH070080",
                "M3035SCH080090",
                "M3040FCI060080",
                "M2325SCI070070",
                "M3035SCH070070",
                "M2735SCI070100",
                "M2730FCI070080",
                "M2530FCI050080",
                "M2035SCI050080",
                "M2330SCI080090",
                "M2527SCI080090",
                "M2030FCI060070",
                "M3545SCI090090",
                "M3335SCI070100",

            };
            int rxInfex = fxMoldSizeList.FindIndex(item => item.Equals(targetMS));
            if (rxInfex != -1)
                Res = true;
            return Res;
        }

    }


}
